forked from extern/nixos-installer
include scripts in build of all-systems, add base.includeNixpkgs option
This commit is contained in:
parent
1f72d9bf26
commit
df3fa46b3c
@ -12,5 +12,5 @@ This is a minimal example for a NixOS system installation function using the fun
|
||||
function install-system {( set -eu # 1: blockDev
|
||||
prepare-installer "$@"
|
||||
do-disk-setup "$1"
|
||||
install-system-to $mnt prompt=true @{config.th.minify.topLevel:-}
|
||||
install-system-to $mnt prompt=true
|
||||
)}
|
||||
|
@ -49,11 +49,7 @@ in { imports = [ ({ ## Hardware
|
||||
fileSystems."/nix/store" = { options = ["bind,ro"]; device = "/system/nix/store"; neededForBoot = true; };
|
||||
|
||||
# Some base config:
|
||||
users.mutableUsers = false; users.allowNoPasswordLogin = true;
|
||||
networking.hostId = lib.mkDefault (builtins.substring 0 8 (builtins.hashString "sha256" config.networking.hostName));
|
||||
environment.etc."machine-id".text = (builtins.substring 0 32 (builtins.hashString "sha256" "${config.networking.hostName}:machine-id"));
|
||||
boot.kernelParams = [ "panic=10" "boot.panic_on_fail" ]; # Reboot on kernel panic, panic if boot fails.
|
||||
systemd.extraConfig = "StatusUnitFormat=name"; # Show unit names instead of descriptions during boot.
|
||||
wip.base.enable = true; wip.base.includeNixpkgs = inputs.nixpkgs;
|
||||
|
||||
# Static config for VBox Adapter 1 set to NAT (the default):
|
||||
networking.interfaces.enp0s3.ipv4.addresses = [ {
|
||||
|
@ -82,9 +82,11 @@ in rec {
|
||||
|
||||
networking.hostName = name;
|
||||
|
||||
system.extraSystemBuilderCmds = if !config.boot.initrd.enable then "" else ''
|
||||
system.extraSystemBuilderCmds = (if !config.boot.initrd.enable then "" else ''
|
||||
ln -sT ${builtins.unsafeDiscardStringContext config.system.build.bootStage1} $out/boot-stage-1.sh # (this is super annoying to locate otherwise)
|
||||
'';
|
||||
'') + (if !inputs?self then "" else ''
|
||||
ln -sT ${inputs.self.outPath} $out/config # (build input for reference)
|
||||
'');
|
||||
|
||||
}) ];
|
||||
specialArgs = specialArgs; # explicitly passing »pkgs« here breaks »config.nixpkgs.overlays«!
|
||||
@ -145,7 +147,7 @@ in rec {
|
||||
... }: let
|
||||
otherArgs = (builtins.removeAttrs args [ "systems" ]) // { inherit systems overlays modules specialArgs scripts inputs configPath nixosSystem localSystem; };
|
||||
nixosConfigurations = if builtins.isList systems then mergeAttrsUnique (map (systems: mkNixosConfigurations (otherArgs // systems)) systems) else mkNixosConfigurations (otherArgs // systems);
|
||||
in {
|
||||
in let outputs = {
|
||||
inherit nixosConfigurations;
|
||||
} // (forEachSystem [ "aarch64-linux" "x86_64-linux" ] (localSystem: let
|
||||
pkgs = (import inputs.nixpkgs { inherit overlays; system = localSystem; });
|
||||
@ -212,6 +214,10 @@ in rec {
|
||||
${lib.concatStringsSep "\n" (lib.mapAttrsToList (name: system: (
|
||||
"ln -sT ${system.config.system.build.toplevel} $out/systems/${name}"
|
||||
)) nixosConfigurations)}
|
||||
${lib.optionalString (scripts != [ ]) ''
|
||||
mkdir -p $out/scripts
|
||||
${lib.concatStringsSep "\n" (lib.mapAttrsToList (name: _: "ln -sT ${outputs.apps.${localSystem}.${name}.program} $out/scripts/${name}") nixosConfigurations)}
|
||||
''}
|
||||
${lib.optionalString (inputs != { }) ''
|
||||
mkdir -p $out/inputs
|
||||
${lib.concatStringsSep "\n" (lib.mapAttrsToList (name: { outPath, ... }: "ln -sT ${outPath} $out/inputs/${name}") inputs)}
|
||||
@ -220,6 +226,6 @@ in rec {
|
||||
'';
|
||||
};
|
||||
|
||||
}));
|
||||
})); in outputs;
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ With the functions from here, adding a simple three-liner can be enough to do a
|
||||
function install-system {( set -eu # 1: blockDev
|
||||
prepare-installer "$@"
|
||||
do-disk-setup "$1"
|
||||
install-system-to $mnt prompt=true @{config.th.minify.topLevel:-}
|
||||
install-system-to $mnt prompt=true
|
||||
)}
|
||||
```
|
||||
|
||||
|
@ -16,6 +16,7 @@ in {
|
||||
|
||||
options.${prefix} = { base = {
|
||||
enable = lib.mkEnableOption "saner defaults";
|
||||
includeNixpkgs = lib.mkOption { description = "»nixpkgs« to include in the system build."; type = lib.types.nullOr lib.types.package; default = null; };
|
||||
}; };
|
||||
|
||||
config = let
|
||||
@ -36,6 +37,16 @@ in {
|
||||
# might additionally want to do this: https://stackoverflow.com/questions/62083796/automatic-reboot-on-systemd-emergency-mode
|
||||
systemd.extraConfig = "StatusUnitFormat=name"; # Show unit names instead of descriptions during boot.
|
||||
|
||||
|
||||
}) (lib.mkIf (cfg.includeNixpkgs != null) {
|
||||
|
||||
nix.registry.nixpkgs.flake = cfg.includeNixpkgs;
|
||||
environment.etc."nix/channels/nixpkgs".source = cfg.includeNixpkgs.outPath;
|
||||
nix.nixPath = [ "nixpkgs=/etc/nix/channels/nixpkgs" "nixos-config=/etc/nixos" ];
|
||||
nix.extraOptions = "experimental-features = nix-command flakes"; # apparently, even nix 2.8 (in nixos-22.05) needs this
|
||||
environment.shellAliases = { "with" = ''nix-shell --run "bash --login" -p''; };
|
||||
|
||||
|
||||
}) ({
|
||||
# Free convenience:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user