]> Git — Sourcephile - sourcephile-nix.git/blob - shell/modules/tools/package-management/nix.nix
mermet: add unlock target.
[sourcephile-nix.git] / shell / modules / tools / package-management / nix.nix
1 { config, lib, pkgs, ... }:
2 let cfg = config.nix;
3 inherit (lib) types;
4 /* Alternative which does not need to re-export envvars when called via sudo.
5 But this is maybe more clear to just (re-)export envvars.
6 nix = pkgs.writeShellScriptBin "nix" ''
7 NIX_CONF_DIR=${cfg.nixConf} \
8 NIX_SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" \
9 SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" \
10 ${pkgs.nix}/bin/nix "$@"
11 '';
12 */
13 in
14 {
15 options.nix = {
16 enable = lib.mkEnableOption "nix";
17 nixConf = lib.mkOption {
18 type = types.lines;
19 apply = s: pkgs.writeText "nix.conf" s;
20 default = ''
21 auto-optimise-store = true
22 '';
23 description = ''
24 Nix's nix.conf content.
25 '';
26 };
27 };
28 config = lib.mkIf cfg.enable {
29 #shell.buildInputs = [ nix ];
30 nix-shell.shellHook = ''
31 # nix
32 export NIX_CONF_DIR=${cfg.nixConf}
33 export NIX_SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
34 export SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
35 '';
36 };
37 }