nixos-configs/nixosModules/base/common-nix/default.nix
matt1432 c4a1822df0
All checks were successful
Discord / discord commits (push) Has been skipped
fix(droid): set nix.package
2024-12-10 23:06:29 -05:00

49 lines
1.2 KiB
Nix

# FIXME: remove unneeded params and reformat
self: {
config,
lib,
pkgs,
...
}: let
inherit (lib) optionalString;
inherit (lib) attrValues filter findFirst isAttrs hasAttr mkDefault mkIf mkOption types;
inherit (self.inputs) home-manager nh nixd;
inherit (self.inputs) nixpkgs;
inherit (config.sops.secrets) access-token;
cfg = config.roles.base;
in {
config = mkIf cfg.enable {
# Minimize dowloads of indirect nixpkgs flakes
nix = {
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;
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;
}