parent
1ce40f2c1a
commit
6ca0d7248b
329 changed files with 178 additions and 139 deletions
modules/base/common-nix
46
modules/base/common-nix/default.nix
Normal file
46
modules/base/common-nix/default.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
self: {
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) attrValues filter findFirst hasAttr isAttrs mkIf optionalString;
|
||||
|
||||
inherit (self.inputs) nixd nixpkgs;
|
||||
inherit (config.sops.secrets) access-token;
|
||||
|
||||
cfg = config.roles.base;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
nix = {
|
||||
# FIXME: infinite recursion if not set
|
||||
package = let
|
||||
nixdInput =
|
||||
findFirst
|
||||
(x: x.pname == "nix") {}
|
||||
nixd.packages.x86_64-linux.nixd.buildInputs;
|
||||
|
||||
throws = x: !(builtins.tryEval x).success;
|
||||
hasVersion = x: isAttrs x && hasAttr "version" x;
|
||||
|
||||
nixVersions = filter (x: ! throws x && hasVersion x) (attrValues pkgs.nixVersions);
|
||||
in
|
||||
findFirst (x: x.version == nixdInput.version) {} nixVersions;
|
||||
|
||||
# Minimize dowloads of indirect nixpkgs flakes
|
||||
registry.nixpkgs.flake = nixpkgs;
|
||||
nixPath = ["nixpkgs=${nixpkgs}"];
|
||||
|
||||
extraOptions =
|
||||
optionalString (hasAttr "sops" config)
|
||||
"!include ${access-token.path}";
|
||||
};
|
||||
|
||||
# Global hm settings
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
};
|
||||
|
||||
# For accurate stack trace
|
||||
_file = ./default.nix;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue