From 09845403be7bbbd74c48033d2d7a8ec561330fc4 Mon Sep 17 00:00:00 2001 From: Charlotte Van Petegem Date: Fri, 10 Mar 2023 16:19:00 +0100 Subject: [PATCH] Use nix-index-database instead of barely-working timer update --- flake.lock | 21 ++++++++++++++++++ flake.nix | 7 +++++- modules/base/nix/default.nix | 43 +++++++----------------------------- 3 files changed, 35 insertions(+), 36 deletions(-) diff --git a/flake.lock b/flake.lock index 2bafa1cf..950991e9 100644 --- a/flake.lock +++ b/flake.lock @@ -243,6 +243,26 @@ "type": "github" } }, + "nix-index-database": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1678095956, + "narHash": "sha256-I8o9R8X7SkqObDWfhBogUNtwAC17qERK97g5LVsHGpA=", + "owner": "Mic92", + "repo": "nix-index-database", + "rev": "4644dcf60506c29ed2cbcd530652b1a1835024b2", + "type": "github" + }, + "original": { + "owner": "Mic92", + "repo": "nix-index-database", + "type": "github" + } + }, "nixos-mailserver": { "inputs": { "blobs": "blobs", @@ -325,6 +345,7 @@ "emacs-overlay": "emacs-overlay", "flake-utils": "flake-utils", "home-manager": "home-manager", + "nix-index-database": "nix-index-database", "nixos-mailserver": "nixos-mailserver", "nixpkgs": "nixpkgs", "nur": "nur", diff --git a/flake.nix b/flake.nix index 791e9bdf..dc64841c 100644 --- a/flake.nix +++ b/flake.nix @@ -62,6 +62,10 @@ }; }; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nix-index-database = { + url = "github:Mic92/nix-index-database"; + inputs.nixpkgs.follows = "nixpkgs"; + }; nur.url = "github:nix-community/NUR"; tetris = { url = "github:chvp/tetris"; @@ -87,7 +91,7 @@ }; }; - outputs = inputs@{ self, nixpkgs, accentor, accentor-api, accentor-web, agenix, devshell, emacs-overlay, flake-utils, home-manager, nixos-mailserver, nur, tetris, utils, www-chvp-be }: + outputs = inputs@{ self, nixpkgs, accentor, accentor-api, accentor-web, agenix, devshell, emacs-overlay, flake-utils, home-manager, nix-index-database, nixos-mailserver, nur, tetris, utils, www-chvp-be }: utils.lib.mkFlake { inherit self inputs; channels.nixpkgs = { @@ -111,6 +115,7 @@ agenix.nixosModules.age home-manager.nixosModule nixos-mailserver.nixosModule + nix-index-database.nixosModules.nix-index ./modules ]; }; diff --git a/modules/base/nix/default.nix b/modules/base/nix/default.nix index 8febe74f..2eab72bf 100644 --- a/modules/base/nix/default.nix +++ b/modules/base/nix/default.nix @@ -8,32 +8,10 @@ let }; }; baseNixIndex = { - home.packages = with pkgs; [ nix-index ]; - programs.zsh.initExtra = '' - source ${pkgs.nix-index}/etc/profile.d/command-not-found.sh - ''; - systemd.user = { - services.nix-index = { - Unit = { - Description = "Service to run nix-index"; - }; - Service = { - Type = "oneshot"; - ExecStart = "${pkgs.nix-index}/bin/nix-index"; - }; - }; - timers.nix-index = { - Unit = { - Description = "Timer that starts nix-index every two hours"; - PartOf = [ "nix-index.service" ]; - }; - Timer = { - OnCalendar = "00/2:30"; - }; - Install = { - WantedBy = [ "default.target" ]; - }; - }; + programs.command-not-found.enable = false; + programs.nix-index = { + enable = true; + package = config.programs.nix-index.package; }; }; in @@ -47,14 +25,10 @@ in default = [ ]; example = [ "teams" ]; }; - # Note that this is only enabled for charlotte, until https://github.com/bennofs/nix-index/issues/143 is resolved. - enableNixIndex = lib.mkOption { - default = true; - example = false; - }; }; config = { + programs.command-not-found.enable = false; chvp.base = { emacs.extraConfig = [ '' @@ -71,8 +45,7 @@ in ''; zfs = { homeLinks = - (lib.optional config.chvp.base.nix.enableDirenv { path = ".local/share/direnv"; type = "cache"; }) ++ - (lib.optional config.chvp.base.nix.enableNixIndex { path = ".cache/nix-index"; type = "cache"; }); + (lib.optional config.chvp.base.nix.enableDirenv { path = ".local/share/direnv"; type = "cache"; }); systemLinks = (lib.optional config.chvp.base.nix.enableDirenv { path = "/root/.local/share/direnv"; type = "cache"; }); }; @@ -112,7 +85,7 @@ in home-manager.users.charlotte = { ... }: lib.recursiveUpdate (lib.optionalAttrs config.chvp.base.nix.enableDirenv baseDirenv) - (lib.optionalAttrs config.chvp.base.nix.enableNixIndex baseNixIndex); - home-manager.users.root = { ... }: lib.optionalAttrs config.chvp.base.nix.enableDirenv baseDirenv; + baseNixIndex; + home-manager.users.root = { ... }: baseNixIndex; }; }