summaryrefslogtreecommitdiff
path: root/system-profiles/core/default.nix
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2023-12-07 20:32:45 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2023-12-07 20:32:45 +0100
commitda6a7d5c69aa3e8b70755e88be0f44b642422114 (patch)
treebb64c8f76a0655b0967d73d7de3541fe2825aa57 /system-profiles/core/default.nix
parent26ba0280e38648a787a5ef60807f91765c40d1d5 (diff)
downloadnixos-da6a7d5c69aa3e8b70755e88be0f44b642422114.tar
nixos-da6a7d5c69aa3e8b70755e88be0f44b642422114.tar.gz
nixos-da6a7d5c69aa3e8b70755e88be0f44b642422114.tar.bz2
nixos-da6a7d5c69aa3e8b70755e88be0f44b642422114.tar.xz
nixos-da6a7d5c69aa3e8b70755e88be0f44b642422114.zip
bump
Diffstat (limited to 'system-profiles/core/default.nix')
-rw-r--r--system-profiles/core/default.nix80
1 files changed, 70 insertions, 10 deletions
diff --git a/system-profiles/core/default.nix b/system-profiles/core/default.nix
index 46049e26..67d50606 100644
--- a/system-profiles/core/default.nix
+++ b/system-profiles/core/default.nix
@@ -1,7 +1,10 @@
1{ flake, flakeInputs, path, hostName, config, lib, pkgs, customUtils, ... }: 1{ flake, flakeInputs, path, hostName, config, lib, pkgs, customUtils, ... }:
2
3with lib;
4
2let 5let
3 profileSet = customUtils.types.attrNameSet flake.nixosModules.systemProfiles; 6 profileSet = customUtils.types.attrNameSet flake.nixosModules.systemProfiles;
4 userProfileSet = customUtils.types.attrNameSet (lib.zipAttrs (lib.attrValues flake.nixosModules.userProfiles)); 7 userProfileSet = customUtils.types.attrNameSet (zipAttrs (attrValues flake.nixosModules.userProfiles));
5 hasSops = config.sops.secrets != {}; 8 hasSops = config.sops.secrets != {};
6in { 9in {
7 imports = with flakeInputs; 10 imports = with flakeInputs;
@@ -11,7 +14,7 @@ in {
11 14
12 options = { 15 options = {
13 # See mkSystemProfile in ../flake.nix 16 # See mkSystemProfile in ../flake.nix
14 system.profiles = lib.mkOption { 17 system.profiles = mkOption {
15 type = profileSet; 18 type = profileSet;
16 default = []; 19 default = [];
17 description = '' 20 description = ''
@@ -19,9 +22,9 @@ in {
19 ''; 22 '';
20 }; 23 };
21 24
22 users.users = lib.mkOption { 25 users.users = mkOption {
23 type = lib.types.attrsOf (lib.types.submodule { 26 type = types.attrsOf (types.submodule {
24 options.profiles = lib.mkOption { 27 options.profiles = mkOption {
25 type = userProfileSet; 28 type = userProfileSet;
26 default = []; 29 default = [];
27 description = '' 30 description = ''
@@ -30,14 +33,71 @@ in {
30 }; 33 };
31 }); 34 });
32 }; 35 };
36
37 nixpkgs.externalConfig = mkOption {
38 default = {};
39 example = literalExpression
40 ''
41 { allowBroken = true; allowUnfree = true; }
42 '';
43 type = mkOptionType {
44 name = "nixpkgs-config";
45 description = "nixpkgs config";
46 check = x:
47 let traceXIfNot = c:
48 if c x then true
49 else traceSeqN 1 x false;
50 isConfig = x:
51 builtins.isAttrs x || isFunction x;
52 in traceXIfNot isConfig;
53 merge = args:
54 let
55 optCall = f: x:
56 if isFunction f
57 then f x
58 else f;
59 mergeConfig = lhs_: rhs_:
60 let
61 lhs = optCall lhs_ { inherit pkgs; };
62 rhs = optCall rhs_ { inherit pkgs; };
63 in
64 recursiveUpdate lhs rhs //
65 optionalAttrs (lhs ? packageOverrides) {
66 packageOverrides = pkgs:
67 optCall lhs.packageOverrides pkgs //
68 optCall (attrByPath [ "packageOverrides" ] { } rhs) pkgs;
69 } //
70 optionalAttrs (lhs ? perlPackageOverrides) {
71 perlPackageOverrides = pkgs:
72 optCall lhs.perlPackageOverrides pkgs //
73 optCall (attrByPath [ "perlPackageOverrides" ] { } rhs) pkgs;
74 };
75 in foldr (def: mergeConfig def.value) {};
76 };
77 description = mdDoc ''
78 The configuration of the Nix Packages collection. (For
79 details, see the Nixpkgs documentation.) It allows you to set
80 package configuration options.
81
82 Used to construct `nixpkgs.pkgs`.
83 '';
84 };
85
86 nixpkgs.flakeInput = mkOption {
87 type = types.enum (attrNames flakeInputs);
88 default = if flakeInputs ? "nixpkgs-${hostName}" then "nixpkgs-${hostName}" else "nixpkgs";
89 defaultText = literalExpression ''if flakeInputs ? "nixpkgs-''${hostName}" then "nixpkgs-''${hostName}" else "nixpkgs"'';
90 internal = true;
91 };
33 }; 92 };
34 93
35 config = { 94 config = {
36 networking.hostName = hostName; 95 networking.hostName = hostName;
37 system.configurationRevision = lib.mkIf (flake ? rev) flake.rev; 96 system.configurationRevision = mkIf (flake ? rev) flake.rev;
38 97
39 nixpkgs.pkgs = flake.legacyPackages.${config.nixpkgs.system}.override { 98 nixpkgs.pkgs = import (flakeInputs.${config.nixpkgs.flakeInput}.outPath + "/pkgs/top-level") {
40 inherit (config.nixpkgs) config; 99 overlays = attrValues flake.overlays;
100 config = config.nixpkgs.externalConfig;
41 localSystem = config.nixpkgs.system; 101 localSystem = config.nixpkgs.system;
42 }; 102 };
43 103
@@ -64,7 +124,7 @@ in {
64 ]; 124 ];
65 registry = 125 registry =
66 let override = { self = "nixos"; }; 126 let override = { self = "nixos"; };
67 in lib.mapAttrs' (inpName: inpFlake: lib.nameValuePair 127 in mapAttrs' (inpName: inpFlake: nameValuePair
68 (override.${inpName} or inpName) 128 (override.${inpName} or inpName)
69 { flake = inpFlake; } ) flakeInputs; 129 { flake = inpFlake; } ) flakeInputs;
70 }; 130 };
@@ -97,7 +157,7 @@ in {
97 backupFileExtension = "bak"; 157 backupFileExtension = "bak";
98 }; 158 };
99 159
100 sops = lib.mkIf hasSops { 160 sops = mkIf hasSops {
101 age = { 161 age = {
102 keyFile = "/var/lib/sops-nix/key.txt"; 162 keyFile = "/var/lib/sops-nix/key.txt";
103 generateKey = false; 163 generateKey = false;