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