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