diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-04-06 14:05:08 +0200 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-04-06 14:05:08 +0200 |
| commit | 8fb207dbb8c944847cc523f844fd05b6e7fe6fae (patch) | |
| tree | d218689404ca881b4aa840f20ed6ac7563c56b1a | |
| parent | ac4ee9ac159a2de4602b420ba4d16c5cd7040039 (diff) | |
| download | nixos-8fb207dbb8c944847cc523f844fd05b6e7fe6fae.tar nixos-8fb207dbb8c944847cc523f844fd05b6e7fe6fae.tar.gz nixos-8fb207dbb8c944847cc523f844fd05b6e7fe6fae.tar.bz2 nixos-8fb207dbb8c944847cc523f844fd05b6e7fe6fae.tar.xz nixos-8fb207dbb8c944847cc523f844fd05b6e7fe6fae.zip | |
...
| -rw-r--r-- | flake.nix | 16 | ||||
| -rw-r--r-- | system-profiles/core.nix | 14 |
2 files changed, 17 insertions, 13 deletions
| @@ -57,7 +57,7 @@ | |||
| 57 | inherit (nixpkgs) lib; | 57 | inherit (nixpkgs) lib; |
| 58 | utils = import ./utils { inherit lib; }; | 58 | utils = import ./utils { inherit lib; }; |
| 59 | inherit (utils) nixImport overrideModule; | 59 | inherit (utils) nixImport overrideModule; |
| 60 | inherit (lib) nixosSystem mkIf splitString filterAttrs listToAttrs mapAttrsToList nameValuePair concatMap composeManyExtensions mapAttrs mapAttrs' recursiveUpdate genAttrs unique elem optionalAttrs isDerivation concatLists concatStringsSep; | 60 | inherit (lib) nixosSystem mkIf splitString filterAttrs listToAttrs mapAttrsToList nameValuePair concatMap composeManyExtensions mapAttrs mapAttrs' recursiveUpdate genAttrs unique elem optionalAttrs isDerivation concatLists concatStringsSep fix filter makeOverridable; |
| 61 | inherit (lib.strings) escapeNixString; | 61 | inherit (lib.strings) escapeNixString; |
| 62 | 62 | ||
| 63 | accountUserName = accountName: | 63 | accountUserName = accountName: |
| @@ -139,7 +139,9 @@ | |||
| 139 | // { imports = [self.nixosModules.users.${userName} or ({...}: { imports = defaultUserProfiles userName; })] ++ (outputs.imports or []); }); | 139 | // { imports = [self.nixosModules.users.${userName} or ({...}: { imports = defaultUserProfiles userName; })] ++ (outputs.imports or []); }); |
| 140 | 140 | ||
| 141 | systemsSelector = "x86_64-linux"; | 141 | systemsSelector = "x86_64-linux"; |
| 142 | forAllSystems = f: mapAttrs f (filterAttrs (system: _systemPkgs: !(isNull (builtins.match systemsSelector system))) nixpkgs.legacyPackages); | 142 | systems = filter (system: !(isNull (builtins.match systemsSelector system))) nixpkgs.lib.systems.supported.hydra; |
| 143 | nixpkgsPackages = localSystem: (makeOverridable (import (nixpkgs.outPath + "/pkgs/top-level"))) { inherit localSystem; }; | ||
| 144 | forAllSystems = f: mapAttrs f (genAttrs systems nixpkgsPackages); | ||
| 143 | forAllUsers = genAttrs (unique (map accountUserName (attrNames self.nixosModules.accounts))); | 145 | forAllUsers = genAttrs (unique (map accountUserName (attrNames self.nixosModules.accounts))); |
| 144 | 146 | ||
| 145 | activateNixosConfigurations = forAllSystems (system: _pkgs: mapAttrs' (hostName: nixosConfig: nameValuePair "${hostName}-activate" { type = "app"; program = "${nixosConfig.config.system.build.toplevel}/bin/switch-to-configuration"; }) self.nixosConfigurations); | 147 | activateNixosConfigurations = forAllSystems (system: _pkgs: mapAttrs' (hostName: nixosConfig: nameValuePair "${hostName}-activate" { type = "app"; program = "${nixosConfig.config.system.build.toplevel}/bin/switch-to-configuration"; }) self.nixosConfigurations); |
| @@ -147,7 +149,7 @@ | |||
| 147 | overlayPaths = nixImport rec { dir = ./overlays; _import = (path: _name: dir + "/${path}"); }; | 149 | overlayPaths = nixImport rec { dir = ./overlays; _import = (path: _name: dir + "/${path}"); }; |
| 148 | 150 | ||
| 149 | installerProfiles = system: | 151 | installerProfiles = system: |
| 150 | let nixpkgs-path = nixpkgs.legacyPackages.${system}.path; | 152 | let nixpkgs-path = nixpkgs.outPath; |
| 151 | in mapAttrs (name: {path, output}: { profile = mkSystemProfile nixpkgs-path path "installer-${name}"; inherit output; }) | 153 | in mapAttrs (name: {path, output}: { profile = mkSystemProfile nixpkgs-path path "installer-${name}"; inherit output; }) |
| 152 | { cd-dvd = { path = "nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"; output = out: out.config.system.build.isoImage; }; | 154 | { cd-dvd = { path = "nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"; output = out: out.config.system.build.isoImage; }; |
| 153 | netboot = { path = "nixos/modules/installer/netboot/netboot-minimal.nix"; output = out: (self.legacyPackages.${system}.symlinkJoin { name = "netboot"; paths = with out.config.system.build; [ netbootRamdisk kernel netbootIpxeScript ]; preferLocalBuild = true; }); }; | 155 | netboot = { path = "nixos/modules/installer/netboot/netboot-minimal.nix"; output = out: (self.legacyPackages.${system}.symlinkJoin { name = "netboot"; paths = with out.config.system.build; [ netbootRamdisk kernel netbootIpxeScript ]; preferLocalBuild = true; }); }; |
| @@ -160,7 +162,7 @@ | |||
| 160 | in forAllSystems (system: _systemPkgs: optionalAttrs (!(isNull installerConfig)) (mkInstallers system)); | 162 | in forAllSystems (system: _systemPkgs: optionalAttrs (!(isNull installerConfig)) (mkInstallers system)); |
| 161 | installerNixosConfigurations = listToAttrs (concatLists (mapAttrsToList (system: mapAttrsToList (profile: { config, ... }: nameValuePair ("installer-${system}-${profile}") config)) installers)); | 163 | installerNixosConfigurations = listToAttrs (concatLists (mapAttrsToList (system: mapAttrsToList (profile: { config, ... }: nameValuePair ("installer-${system}-${profile}") config)) installers)); |
| 162 | 164 | ||
| 163 | packages = forAllSystems (system: systemPkgs: composeManyExtensions (attrValues self.overlays) self.legacyPackages.${system} systemPkgs); | 165 | # packages = forAllSystems (system: systemPkgs: composeManyExtensions (attrValues self.overlays) self.legacyPackages.${system} systemPkgs); |
| 164 | 166 | ||
| 165 | activateHomeManager = system: base: (deploy-rs.lib.${system}.activate.custom // { dryActivate = "DRY_RUN=1 $PROFILE/activate"; }) base.activationPackage "$PROFILE/activate"; | 167 | activateHomeManager = system: base: (deploy-rs.lib.${system}.activate.custom // { dryActivate = "DRY_RUN=1 $PROFILE/activate"; }) base.activationPackage "$PROFILE/activate"; |
| 166 | in | 168 | in |
| @@ -180,10 +182,10 @@ | |||
| 180 | 182 | ||
| 181 | overlays = mapAttrs (_name: path: mkOverlay path) overlayPaths; | 183 | overlays = mapAttrs (_name: path: mkOverlay path) overlayPaths; |
| 182 | 184 | ||
| 183 | packages = mapAttrs (_name: filterAttrs (_name: isDerivation)) packages; | 185 | # packages = mapAttrs (_name: filterAttrs (_name: isDerivation)) packages; |
| 184 | packages' = mapAttrs (_name: filterAttrs (_name: value: !(isDerivation value))) packages; | 186 | # packages' = mapAttrs (_name: filterAttrs (_name: value: !(isDerivation value))) packages; |
| 185 | 187 | ||
| 186 | legacyPackages = forAllSystems (system: systemPkgs: recursiveUpdate systemPkgs packages.${system}); | 188 | legacyPackages = forAllSystems (system: systemPkgs: systemPkgs.override { overlays = attrValues self.overlays; }); |
| 187 | 189 | ||
| 188 | apps = activateNixosConfigurations; | 190 | apps = activateNixosConfigurations; |
| 189 | 191 | ||
diff --git a/system-profiles/core.nix b/system-profiles/core.nix index c808e123..6a38d9ce 100644 --- a/system-profiles/core.nix +++ b/system-profiles/core.nix | |||
| @@ -36,9 +36,9 @@ in { | |||
| 36 | networking.hostName = hostName; | 36 | networking.hostName = hostName; |
| 37 | system.configurationRevision = lib.mkIf (flake ? rev) flake.rev; | 37 | system.configurationRevision = lib.mkIf (flake ? rev) flake.rev; |
| 38 | 38 | ||
| 39 | nixpkgs.pkgs = import flake.legacyPackages.${config.nixpkgs.system}.path { | 39 | nixpkgs.pkgs = flake.legacyPackages.${config.nixpkgs.system}.override { |
| 40 | inherit (config.nixpkgs) system config; | 40 | inherit (config.nixpkgs) config; |
| 41 | overlays = lib.attrValues (lib.filterAttrs (n: _v: n != "default") flake.overlays); | 41 | localSystem = config.nixpkgs.system; |
| 42 | }; | 42 | }; |
| 43 | 43 | ||
| 44 | nix = { | 44 | nix = { |
| @@ -52,11 +52,13 @@ in { | |||
| 52 | experimental-features = nix-command flakes | 52 | experimental-features = nix-command flakes |
| 53 | ''; | 53 | ''; |
| 54 | nixPath = [ | 54 | nixPath = [ |
| 55 | "nixpkgs=${flakeInputs.nixpkgs.legacyPackages.${config.nixpkgs.system}.path}" | 55 | "nixpkgs=${flakeInputs.nixpkgs.outPath}" |
| 56 | "nixpkgs-overlays=${pkgs.writeText "overlays.nix" '' | 56 | "nixpkgs-overlays=${pkgs.writeText "overlays.nix" '' |
| 57 | builtins.attrValues (import | 57 | with builtins; |
| 58 | |||
| 59 | attrValues (import | ||
| 58 | ( | 60 | ( |
| 59 | let lock = builtins.fromJSON (builtins.readFile ${toString ../flake.lock}); in | 61 | let lock = fromJSON (readFile ${toString ../flake.lock}); in |
| 60 | fetchTarball { | 62 | fetchTarball { |
| 61 | url = "https://github.com/edolstra/flake-compat/archive/''${lock.nodes.flake-compat.locked.rev}.tar.gz"; | 63 | url = "https://github.com/edolstra/flake-compat/archive/''${lock.nodes.flake-compat.locked.rev}.tar.gz"; |
| 62 | sha256 = lock.nodes.flake-compat.locked.narHash; | 64 | sha256 = lock.nodes.flake-compat.locked.narHash; |
