mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
chore(overlays): trivial builder wrappers
This commit is contained in:
parent
7744e4389d
commit
7017c8c5f9
4 changed files with 134 additions and 13 deletions
|
|
@ -1,7 +1,32 @@
|
||||||
{gensokyo-zone, ...}: let
|
{
|
||||||
|
config,
|
||||||
|
system,
|
||||||
|
gensokyo-zone,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (gensokyo-zone.lib) mkAlmostForce;
|
||||||
|
inherit (lib.options) mkOption;
|
||||||
|
inherit (lib.modules) mkIf mkDefault;
|
||||||
|
inherit (lib.attrsets) optionalAttrs;
|
||||||
inherit (gensokyo-zone.self) overlays;
|
inherit (gensokyo-zone.self) overlays;
|
||||||
|
cfg = config.nixpkgs;
|
||||||
|
hostPlatform = lib.systems.elaborate {
|
||||||
|
inherit (system) system;
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
nixpkgs = {
|
options.nixpkgs = with lib.types; {
|
||||||
|
usePkgs = mkOption {
|
||||||
|
type = enum ["legacyPackages.pkgs" "import" "nixos"];
|
||||||
|
description = "gensokyo-zone#legacyPackages.pkgs";
|
||||||
|
default =
|
||||||
|
if cfg.buildPlatform == cfg.hostPlatform && cfg.hostPlatform == hostPlatform && gensokyo-zone.self ? legacyPackages.${cfg.hostPlatform.system}.pkgs
|
||||||
|
then "legacyPackages.pkgs"
|
||||||
|
else "import";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config.nixpkgs = {
|
||||||
|
hostPlatform = mkDefault hostPlatform;
|
||||||
overlays = [
|
overlays = [
|
||||||
gensokyo-zone.inputs.arcexprs.overlays.default
|
gensokyo-zone.inputs.arcexprs.overlays.default
|
||||||
overlays.default
|
overlays.default
|
||||||
|
|
@ -13,4 +38,18 @@ in {
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
config._module.args.pkgs = let
|
||||||
|
pkgsArgs = {
|
||||||
|
inherit (cfg) config overlays;
|
||||||
|
localSystem = cfg.buildPlatform;
|
||||||
|
};
|
||||||
|
pkgsCrossArgs = optionalAttrs (cfg.buildPlatform != cfg.hostPlatform) {
|
||||||
|
crossSystem = cfg.hostPlatform;
|
||||||
|
};
|
||||||
|
pkgs = {
|
||||||
|
"legacyPackages.pkgs" = gensokyo-zone.self.legacyPackages.${cfg.hostPlatform.system}.pkgs;
|
||||||
|
import = import gensokyo-zone.inputs.nixpkgs (pkgsArgs // pkgsCrossArgs);
|
||||||
|
};
|
||||||
|
in
|
||||||
|
mkIf (cfg.usePkgs != "nixos") (mkAlmostForce pkgs.${cfg.usePkgs}.__withSubBuilders);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
devShells = import ./devShells.nix {inherit system inputs;};
|
devShells = import ./devShells.nix {inherit system inputs;};
|
||||||
packages = import ./packages {inherit system inputs;};
|
packages = import ./packages {inherit system inputs;};
|
||||||
legacyPackages = {
|
legacyPackages = {
|
||||||
|
pkgs = let
|
||||||
pkgs = import inputs.nixpkgs {
|
pkgs = import inputs.nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = [
|
overlays = [
|
||||||
|
|
@ -26,6 +27,9 @@
|
||||||
allowUnfree = true;
|
allowUnfree = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
# see overlays/builders.nix
|
||||||
|
in
|
||||||
|
pkgs.__withSubBuilders;
|
||||||
patchedNixpkgs = pkgs.applyPatches {
|
patchedNixpkgs = pkgs.applyPatches {
|
||||||
name = "nixpkgs";
|
name = "nixpkgs";
|
||||||
src = inputs.nixpkgs;
|
src = inputs.nixpkgs;
|
||||||
|
|
|
||||||
76
overlays/builders.nix
Normal file
76
overlays/builders.nix
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
final: prev: let
|
||||||
|
inherit (final.lib.attrsets) mapAttrs' nameValuePair;
|
||||||
|
subBuilders = {
|
||||||
|
applyPatches = args:
|
||||||
|
prev.applyPatches ({
|
||||||
|
allowSubstitutes = true;
|
||||||
|
}
|
||||||
|
// args);
|
||||||
|
writeTextFile = args:
|
||||||
|
prev.writeTextFile ({
|
||||||
|
allowSubstitutes = true;
|
||||||
|
}
|
||||||
|
// args);
|
||||||
|
writeText = name: text: final.writeTextFile' {inherit name text;};
|
||||||
|
writeShellScript = name: text:
|
||||||
|
final.writeTextFile' {
|
||||||
|
inherit name;
|
||||||
|
executable = true;
|
||||||
|
text = ''
|
||||||
|
#!${final.runtimeShell}
|
||||||
|
${text}
|
||||||
|
'';
|
||||||
|
checkPhase = ''
|
||||||
|
${final.stdenv.shellDryRun} "$target"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
writeShellScriptBin = name: text:
|
||||||
|
final.writeTextFile' {
|
||||||
|
inherit name;
|
||||||
|
destination = "/bin/${name}";
|
||||||
|
executable = true;
|
||||||
|
text = ''
|
||||||
|
#!${final.runtimeShell}
|
||||||
|
${text}
|
||||||
|
'';
|
||||||
|
checkPhase = ''
|
||||||
|
${final.stdenv.shellDryRun} "$target"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
symlinkJoin = args:
|
||||||
|
prev.symlinkJoin ({
|
||||||
|
allowSubstitutes = true;
|
||||||
|
}
|
||||||
|
// args);
|
||||||
|
linkFarm = name: entries:
|
||||||
|
(prev.linkFarm name entries).overrideAttrs (_: {
|
||||||
|
allowSubstitutes = true;
|
||||||
|
});
|
||||||
|
runCommandLocal = name: env:
|
||||||
|
final.runCommandWith {
|
||||||
|
stdenv = final.stdenvNoCC;
|
||||||
|
runLocal = true;
|
||||||
|
inherit name;
|
||||||
|
derivationArgs =
|
||||||
|
{
|
||||||
|
allowSubstitutes = true;
|
||||||
|
}
|
||||||
|
// env;
|
||||||
|
};
|
||||||
|
# TODO: writeScript, writeScriptBin, runCommandWith...
|
||||||
|
};
|
||||||
|
subBuilders' = mapAttrs' (name: nameValuePair "${name}'") subBuilders;
|
||||||
|
in {
|
||||||
|
inherit
|
||||||
|
(subBuilders')
|
||||||
|
applyPatches'
|
||||||
|
writeTextFile'
|
||||||
|
writeText'
|
||||||
|
writeShellScript'
|
||||||
|
writeShellScriptBin'
|
||||||
|
symlinkJoin'
|
||||||
|
linkFarm'
|
||||||
|
runCommandLocal'
|
||||||
|
;
|
||||||
|
__withSubBuilders = final // subBuilders;
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
in rec {
|
in rec {
|
||||||
default = nixlib.composeManyExtensions [
|
default = nixlib.composeManyExtensions [
|
||||||
barcodebuddy
|
barcodebuddy
|
||||||
|
builders
|
||||||
krb5
|
krb5
|
||||||
minecraft
|
minecraft
|
||||||
nfs
|
nfs
|
||||||
|
|
@ -17,6 +18,7 @@ in rec {
|
||||||
nginx = import ./nginx.nix;
|
nginx = import ./nginx.nix;
|
||||||
samba = import ./samba.nix;
|
samba = import ./samba.nix;
|
||||||
openwebrx = import ./openwebrxplus.nix;
|
openwebrx = import ./openwebrxplus.nix;
|
||||||
|
builders = import ./builders.nix;
|
||||||
deploy-rs = inputs.deploy-rs.overlays.default or inputs.deploy-rs.overlay;
|
deploy-rs = inputs.deploy-rs.overlays.default or inputs.deploy-rs.overlay;
|
||||||
systemd2mqtt = inputs.systemd2mqtt.overlays.default;
|
systemd2mqtt = inputs.systemd2mqtt.overlays.default;
|
||||||
arc = inputs.arcexprs.overlays.default;
|
arc = inputs.arcexprs.overlays.default;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue