Use nix-index-database instead of barely-working timer update

This commit is contained in:
Charlotte Van Petegem 2023-03-10 16:19:00 +01:00
parent 68ec7d8f7c
commit 09845403be
No known key found for this signature in database
GPG key ID: 019E764B7184435A
3 changed files with 35 additions and 36 deletions

21
flake.lock generated
View file

@ -243,6 +243,26 @@
"type": "github" "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": { "nixos-mailserver": {
"inputs": { "inputs": {
"blobs": "blobs", "blobs": "blobs",
@ -325,6 +345,7 @@
"emacs-overlay": "emacs-overlay", "emacs-overlay": "emacs-overlay",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"home-manager": "home-manager", "home-manager": "home-manager",
"nix-index-database": "nix-index-database",
"nixos-mailserver": "nixos-mailserver", "nixos-mailserver": "nixos-mailserver",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nur": "nur", "nur": "nur",

View file

@ -62,6 +62,10 @@
}; };
}; };
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 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"; nur.url = "github:nix-community/NUR";
tetris = { tetris = {
url = "github:chvp/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 { utils.lib.mkFlake {
inherit self inputs; inherit self inputs;
channels.nixpkgs = { channels.nixpkgs = {
@ -111,6 +115,7 @@
agenix.nixosModules.age agenix.nixosModules.age
home-manager.nixosModule home-manager.nixosModule
nixos-mailserver.nixosModule nixos-mailserver.nixosModule
nix-index-database.nixosModules.nix-index
./modules ./modules
]; ];
}; };

View file

@ -8,32 +8,10 @@ let
}; };
}; };
baseNixIndex = { baseNixIndex = {
home.packages = with pkgs; [ nix-index ]; programs.command-not-found.enable = false;
programs.zsh.initExtra = '' programs.nix-index = {
source ${pkgs.nix-index}/etc/profile.d/command-not-found.sh enable = true;
''; package = config.programs.nix-index.package;
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" ];
};
};
}; };
}; };
in in
@ -47,14 +25,10 @@ in
default = [ ]; default = [ ];
example = [ "teams" ]; 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 = { config = {
programs.command-not-found.enable = false;
chvp.base = { chvp.base = {
emacs.extraConfig = [ emacs.extraConfig = [
'' ''
@ -71,8 +45,7 @@ in
''; '';
zfs = { zfs = {
homeLinks = homeLinks =
(lib.optional config.chvp.base.nix.enableDirenv { path = ".local/share/direnv"; type = "cache"; }) ++ (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"; });
systemLinks = systemLinks =
(lib.optional config.chvp.base.nix.enableDirenv { path = "/root/.local/share/direnv"; type = "cache"; }); (lib.optional config.chvp.base.nix.enableDirenv { path = "/root/.local/share/direnv"; type = "cache"; });
}; };
@ -112,7 +85,7 @@ in
home-manager.users.charlotte = { ... }: home-manager.users.charlotte = { ... }:
lib.recursiveUpdate lib.recursiveUpdate
(lib.optionalAttrs config.chvp.base.nix.enableDirenv baseDirenv) (lib.optionalAttrs config.chvp.base.nix.enableDirenv baseDirenv)
(lib.optionalAttrs config.chvp.base.nix.enableNixIndex baseNixIndex); baseNixIndex;
home-manager.users.root = { ... }: lib.optionalAttrs config.chvp.base.nix.enableDirenv baseDirenv; home-manager.users.root = { ... }: baseNixIndex;
}; };
} }