about summary refs log tree commit diff
path: root/nixos/modules/flakes.nix
blob: 76f89f3bdb256c2711356a06f184217e4572c655 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{ config, pkgs, unstable, unstable-small, nixpkgs-2211, lib, ... }:

let
  base = "/etc/nixpkgs/channels";
  nixpkgsPath = "${base}/nixpkgs";
  nixpkgsSmallPath = "${base}/nixpkgsSmall";
  nixpkgs2211Path = "${base}/nixpkgs2211";
in
{
  options.nix.flakes.enable = lib.mkEnableOption "nix flakes";

  config = lib.mkIf config.nix.flakes.enable {
    nix = {
      package = pkgs.nixUnstable;
      experimentalFeatures = "nix-command flakes";

      registry.nixpkgs.flake = unstable;
      registry.nixpkgsSmall.flake = unstable-small;
      registry.nixpkgs2211.flake = nixpkgs-2211;

      nixPath = [
        "nixpkgs=${nixpkgsPath}"
        "nixpkgsSmall=${nixpkgsSmallPath}"
        "nixpkgs2211=${nixpkgs2211Path}"
        "/nix/var/nix/profiles/per-user/root/channels"
      ];
    };

    systemd.tmpfiles.rules = [
      "L+ ${nixpkgsPath}         - - - - ${unstable}"
      "L+ ${nixpkgsSmallPath} - - - - ${unstable-small}"
      "L+ ${nixpkgs2211Path} - - - - ${nixpkgs-2211}"
    ];
  };
}