]> Git — Sourcephile - julm/julm-nix.git/blob - flake.nix
nix: update nixpkgs
[julm/julm-nix.git] / flake.nix
1 {
2 inputs.nixpkgs.url = "github:NixOS/nixpkgs/495b19d5b3e62b4ec7e846bdfb6ef3d9c3b83492";
3 inputs.flake-utils.url = "github:numtide/flake-utils";
4 inputs.home-manager.url = "github:nix-community/home-manager";
5 inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs";
6 inputs.doom-emacs.url = "github:hlissner/doom-emacs";
7 inputs.doom-emacs.flake = false;
8 inputs.nix-doom-emacs.url = "github:vlaci/nix-doom-emacs";
9 inputs.nix-doom-emacs.inputs.nixpkgs.follows = "nixpkgs";
10 inputs.nix-doom-emacs.inputs.home-manager.follows = "home-manager";
11 inputs.nix-doom-emacs.inputs.flake-utils.follows = "flake-utils";
12 inputs.nix-doom-emacs.inputs.emacs-overlay.follows = "emacs-overlay";
13 inputs.emacs-overlay.url = "github:nix-community/emacs-overlay/master";
14 #inputs.pass = { type = "path"; path = "./pass"; flake = false; };
15
16 outputs = inputs: let
17 remoteNixpkgsPatches = import nixpkgs/patches.nix;
18 localNixpkgsPatches = [
19 nixpkgs/patches/openvpn.diff
20 ];
21 originPkgs = inputs.nixpkgs.legacyPackages."x86_64-linux";
22 nixpkgsPath = originPkgs.applyPatches {
23 name = "nixpkgs-patched";
24 src = inputs.nixpkgs.outPath;
25 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
26 postPatch = ''
27 patch=$(printf '%s\n' ${builtins.concatStringsSep " "
28 (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)} |
29 sort | sha256sum | cut -c -7)
30 echo "-patch-$patch" >.version-suffix
31 '';
32 };
33 lib = originPkgs.lib;
34 nixosSystem = import (nixpkgsPath + "/nixos/lib/eval-config.nix");
35 #nixosSystem = inputs.nixpkgs.lib.nixosSystem;
36 in {
37 nixosConfigurations = lib.genAttrs
38 (builtins.attrNames (lib.filterAttrs (n: v: v == "directory") (builtins.readDir ./hosts)))
39 (hostName: nixosSystem rec {
40 system = "x86_64-linux";
41 specialArgs = {
42 inherit hostName inputs;
43 # Encrypted using git-crypt, hence kept out of /nix/store
44 private = "/root/private";
45 # Encrypted using systemd-creds, hence can go into the /nix/store
46 credentials = private/credentials + "/${hostName}";
47 };
48 pkgs = import nixpkgsPath {
49 inherit system;
50 config.allowUnfree = true; # For hplip
51 overlays = import nixpkgs/overlays.nix;
52 };
53 modules = [
54 {
55 config._module.args = {
56 inherit hostName inputs;
57 hosts = inputs.self.nixosConfigurations;
58 };
59 }
60 (import (./hosts + "/${hostName}.nix"))
61 inputs.nixpkgs.nixosModules.notDetected
62 inputs.home-manager.nixosModules.home-manager
63 ({ pkgs, ... }: {
64 nix.registry.nixpkgs = lib.mkDefault { flake = inputs.nixpkgs; };
65 nix.package = pkgs.nixFlakes;
66 nix.extraOptions = "experimental-features = nix-command flakes";
67 #nixpkgs.overlays = import nixpkgs/overlays.nix;
68 /*
69 system.nixos.versionSuffix = ".${
70 lib.substring 0 8 (inputs.self.lastModifiedDate or inputs.self.lastModified)}.${
71 inputs.self.shortRev or "dirty"}";
72 system.nixos.revision = lib.mkIf (inputs.self ? rev) inputs.self.rev;
73 */
74 # Let 'nixos-version --json' know about the Git revision of this flake.
75 system.configurationRevision = lib.mkIf (inputs.self ? rev) inputs.self.rev;
76 /*
77 system.configurationRevision =
78 if inputs.self ? rev
79 then inputs.self.rev
80 else throw "Refusing to build from a dirty Git tree!";
81 */
82 })
83 {
84 home-manager.useGlobalPkgs = true;
85 home-manager.useUserPackages = true;
86 home-manager.verbose = true;
87 home-manager.backupFileExtension = null;
88 home-manager.extraSpecialArgs = {
89 inherit hostName inputs;
90 };
91 }
92 ];
93 });
94 } //
95 inputs.flake-utils.lib.eachDefaultSystem (system:
96 #let pkgs = inputs.nixpkgs.legacyPackages.${system}; in
97 let
98 pkgs = import nixpkgsPath {
99 inherit system;
100 config = {}; # Make the config pure, ignoring user's config.
101 overlays = import nixpkgs/overlays.nix;
102 }; in {
103 devShell = import ./shell.nix { inherit pkgs inputs system; };
104 }
105 );
106 }