feat: add nix-monitored

This commit is contained in:
Moritz Böhme 2024-02-16 11:02:24 +01:00
parent d098a8f907
commit 66cbbaa4ba
No known key found for this signature in database
GPG key ID: 970C6E89EB0547A9
3 changed files with 105 additions and 67 deletions

View file

@ -9,6 +9,22 @@
with lib;
let
cfg = config.my.programs.nix;
mkSuper = system: nix:
if cfg.useSuper
then inputs.nix-super.packages.${system}.default
else nix;
mkNom = system: nix:
if cfg.useNom
then
inputs.nix-monitored.packages.${system}.default.override
{
nix = nix;
}
else nix;
mkNix = system: nix: mkNom system (mkSuper system nix);
in
{
options.my.programs.nix = {
@ -21,48 +37,65 @@ in
};
};
optimise.enable = mkEnableOption "nix-optimise";
useSuper = mkEnableOption "use nix super" // { default = true; };
useNom = mkEnableOption "use nix output monitor by default" // { default = true; };
};
config.nix = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
config = {
my.nixpkgs.overlays = [
(final: prev:
{
nixos-rebuild = prev.nixos-rebuild.override {
nix = mkNom final.system final.nix;
};
})
];
package = inputs.nix-super.packages.${pkgs.system}.default;
extraOptions = "experimental-features = nix-command flakes";
gc = {
automatic = cfg.gc.enable;
options = "--max-freed ${cfg.gc.minimumFreedGB} --delete-older-than 14d";
dates = "weekly";
home-manager.users.moritz.programs.direnv.nix-direnv.package = pkgs.nix-direnv.override {
nix = config.nix.package;
};
optimise = {
automatic = cfg.optimise.enable;
dates = [ "weekly" ];
};
nix = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
registry = {
master-upstream.to = {
type = "github";
owner = "nixos";
repo = "nixpkgs";
package = mkNix pkgs.system pkgs.nix;
extraOptions = "experimental-features = nix-command flakes";
gc = {
automatic = cfg.gc.enable;
options = "--max-freed ${cfg.gc.minimumFreedGB} --delete-older-than 14d";
dates = "weekly";
};
master.flake = inputs.master;
nixpkgs.flake = inputs.nixpkgs;
stable.flake = inputs.stable;
dotfiles.flake = self;
default.flake = self;
};
settings = {
substituters = [
"https://cache.nixos.org/"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
optimise = {
automatic = cfg.optimise.enable;
dates = [ "weekly" ];
};
trusted-users = [ "root" "@wheel" ];
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;
};
settings = {
substituters = [
"https://cache.nixos.org/"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
trusted-users = [ "root" "@wheel" ];
};
};
};
}