From 66cbbaa4bad6b79292ea96b2dba52ab3291227ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Fri, 16 Feb 2024 11:02:24 +0100 Subject: [PATCH] feat: add nix-monitored --- flake.lock | 71 ++++++++++++++-------------- flake.nix | 2 + modules/programs/nix.nix | 99 ++++++++++++++++++++++++++-------------- 3 files changed, 105 insertions(+), 67 deletions(-) diff --git a/flake.lock b/flake.lock index 6f7948c..dfeef5b 100644 --- a/flake.lock +++ b/flake.lock @@ -662,6 +662,21 @@ "type": "github" } }, + "nix-filter": { + "locked": { + "lastModified": 1687178632, + "narHash": "sha256-HS7YR5erss0JCaUijPeyg2XrisEb959FIct3n2TMGbE=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "d90c75e8319d0dd9be67d933d8eb9d0894ec9174", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, "nix-index-database": { "inputs": { "nixpkgs": [ @@ -697,6 +712,27 @@ "url": "https://git.moritzboeh.me/moritz/NixLazy.nvim" } }, + "nix-monitored": { + "inputs": { + "nix-filter": "nix-filter", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1692605628, + "narHash": "sha256-jBasvDCk9V32JuwtPy1G4KyVAc2eaBSf2X5eRNQgIkY=", + "owner": "ners", + "repo": "nix-monitored", + "rev": "6be92b0c1eca7ef501b4f92735885e7cb4db414b", + "type": "github" + }, + "original": { + "owner": "ners", + "repo": "nix-monitored", + "type": "github" + } + }, "nix-super": { "inputs": { "flake-compat": "flake-compat_2", @@ -960,38 +996,6 @@ "type": "github" } }, - "nvim-puppeteer": { - "flake": false, - "locked": { - "lastModified": 1706210708, - "narHash": "sha256-tjL4qC1VAad4NXaZFDhTcmbrbdqNpVm7/MnyR/CE3rw=", - "owner": "chrisgrieser", - "repo": "nvim-puppeteer", - "rev": "048c819c8033e5febe0a04e63b98e74a5d0f8de6", - "type": "github" - }, - "original": { - "owner": "chrisgrieser", - "repo": "nvim-puppeteer", - "type": "github" - } - }, - "nvim-treesitter": { - "flake": false, - "locked": { - "lastModified": 1706272330, - "narHash": "sha256-R+oQGVcmncAd39D5AkGV1HAPgGDPMiucrC1GHMLh/Xk=", - "owner": "nvim-treesitter", - "repo": "nvim-treesitter", - "rev": "efda19a54a157da8635aa6cb84f56a10593b1a23", - "type": "github" - }, - "original": { - "owner": "nvim-treesitter", - "repo": "nvim-treesitter", - "type": "github" - } - }, "pre-commit-hooks": { "inputs": { "flake-compat": "flake-compat_3", @@ -1035,13 +1039,12 @@ "neovim-nightly-overlay": "neovim-nightly-overlay", "nix-index-database": "nix-index-database", "nix-lazy-nvim": "nix-lazy-nvim", + "nix-monitored": "nix-monitored", "nix-super": "nix-super", "nixpkgs": "nixpkgs_7", "none-ls-nvim": "none-ls-nvim", "nur": "nur", "nvim-lspconfig": "nvim-lspconfig", - "nvim-puppeteer": "nvim-puppeteer", - "nvim-treesitter": "nvim-treesitter", "pre-commit-hooks": "pre-commit-hooks", "smartcolumn-nvim": "smartcolumn-nvim", "stable": "stable", diff --git a/flake.nix b/flake.nix index 73d837f..cd06bd0 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,8 @@ # Programs nix-super.url = "github:privatevoid-net/nix-super"; + nix-monitored.url = "github:ners/nix-monitored"; + nix-monitored.inputs.nixpkgs.follows = "nixpkgs"; timers.url = "git+https://gitea.moritzboeh.me/moritz/timers.git"; # Neovim diff --git a/modules/programs/nix.nix b/modules/programs/nix.nix index 2ee8475..a1b5219 100644 --- a/modules/programs/nix.nix +++ b/modules/programs/nix.nix @@ -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" ]; + }; }; }; }