2022-07-15 13:11:54 +02:00
|
|
|
{ config
|
|
|
|
, lib
|
2022-09-03 11:31:21 +02:00
|
|
|
, 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
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
2023-05-07 13:59:01 +02:00
|
|
|
cfg = config.my.programs.nix;
|
2024-02-16 11:02:24 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2024-02-16 11:28:08 +01:00
|
|
|
withNotify = false;
|
2024-02-16 11:02:24 +01:00
|
|
|
nix = nix;
|
|
|
|
}
|
|
|
|
else nix;
|
|
|
|
|
|
|
|
mkNix = system: nix: mkNom system (mkSuper system nix);
|
2022-07-15 13:11:54 +02:00
|
|
|
in
|
|
|
|
{
|
2023-05-07 13:59:01 +02:00
|
|
|
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";
|
2024-04-21 11:54:18 +02:00
|
|
|
useSuper = mkEnableOption "use nix super";
|
|
|
|
useNom = mkEnableOption "use nix output monitor" // { default = true; };
|
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-02-16 11:02:24 +01:00
|
|
|
nix = {
|
|
|
|
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
|
2023-06-11 10:25:45 +02:00
|
|
|
|
2024-02-16 11:02:24 +01:00
|
|
|
package = mkNix pkgs.system pkgs.nix;
|
2022-07-15 13:11:54 +02:00
|
|
|
|
2024-02-16 11:02:24 +01:00
|
|
|
extraOptions = "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" ];
|
2022-09-03 11:31:21 +02:00
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|