dotfiles/modules/programs/nix.nix

97 lines
2.1 KiB
Nix
Raw Normal View History

2022-07-15 13:11:54 +02:00
{ config
, lib
, inputs
2023-05-12 15:14:08 +02:00
, self
2023-05-29 12:48:43 +02:00
, pkgs
2022-07-15 13:11:54 +02:00
, ...
}:
let
2024-08-18 13:05:32 +02:00
inherit (lib) mkEnableOption mkOption types;
2024-02-16 11:02:24 +01:00
2024-08-18 13:05:32 +02:00
cfg = config.my.programs.nix;
2024-02-16 11:02:24 +01:00
mkNom = system: nix:
2024-08-18 13:05:32 +02:00
inputs.nix-monitored.packages.${system}.default.override
{
withNotify = false;
nix = nix;
};
2022-07-15 13:11:54 +02:00
in
{
options.my.programs.nix = {
2022-10-15 20:00:09 +02:00
gc = {
enable = mkEnableOption "nix-gc";
minimumFreedGB = mkOption {
default = 32;
type = types.int;
apply = number: toString (number * 1024 * 1024 * 1024);
};
2022-07-15 13:11:54 +02:00
};
2022-10-15 20:00:09 +02:00
optimise.enable = mkEnableOption "nix-optimise";
2022-07-15 13:11:54 +02:00
};
2024-02-16 11:02:24 +01:00
config = {
my.nixpkgs.overlays = [
(final: prev:
{
nixos-rebuild = prev.nixos-rebuild.override {
nix = mkNom final.system final.nix;
};
})
];
2023-09-06 08:36:16 +02:00
2024-02-16 11:02:24 +01:00
home-manager.users.moritz.programs.direnv.nix-direnv.package = pkgs.nix-direnv.override {
nix = config.nix.package;
};
2023-05-12 15:13:27 +02:00
2024-10-25 11:16:29 +02:00
age.secrets.nix-github-token.file = ../../secrets/nix-github-token.age;
2024-02-16 11:02:24 +01:00
nix = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
2024-11-08 19:40:51 +01:00
package = pkgs.lix;
2022-07-15 13:11:54 +02:00
2024-10-25 11:16:29 +02:00
extraOptions = ''
!include ${config.age.secrets.nix-github-token.path}
experimental-features = nix-command flakes
'';
2022-07-15 13:11:54 +02:00
2024-02-16 11:02:24 +01:00
gc = {
automatic = cfg.gc.enable;
options = "--max-freed ${cfg.gc.minimumFreedGB} --delete-older-than 14d";
dates = "weekly";
};
optimise = {
automatic = cfg.optimise.enable;
dates = [ "weekly" ];
};
2024-02-16 11:02:24 +01:00
registry = {
master-upstream.to = {
type = "github";
owner = "nixos";
repo = "nixpkgs";
};
master.flake = inputs.master;
nixpkgs.flake = inputs.nixpkgs;
stable.flake = inputs.stable;
dotfiles.flake = self;
default.flake = self;
d.flake = self;
2024-02-16 11:02:24 +01:00
};
settings = {
substituters = [
"https://cache.nixos.org/"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
2022-07-15 13:11:54 +02:00
2024-02-16 11:02:24 +01:00
trusted-users = [ "root" "@wheel" ];
};
2022-07-15 13:11:54 +02:00
};
};
}