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"
}
},
"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",

View file

@ -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
];
};

View file

@ -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;
};
}