diff --git a/flake.lock b/flake.lock index 14086e8..32a92b1 100644 --- a/flake.lock +++ b/flake.lock @@ -44,7 +44,24 @@ } }, "attic": { - "flake": false, + "inputs": { + "crane": [ + "crane" + ], + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "lix": [ + "lix" + ], + "lix-module": [ + "lix-module" + ], + "nix-github-actions": "nix-github-actions", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, "locked": { "lastModified": 1742679462, "narHash": "sha256-L9q9KDqiJEREM/GRnSo4vB9VCvclmdRT9vXuFwBmb9Y=", @@ -93,28 +110,12 @@ } }, "crane": { - "flake": false, "locked": { - "lastModified": 1745454774, - "narHash": "sha256-oLvmxOnsEKGtwczxp/CwhrfmQUG2ym24OMWowcoRhH8=", + "lastModified": 1742394900, + "narHash": "sha256-vVOAp9ahvnU+fQoKd4SEXB2JG2wbENkpqcwlkIXgUC0=", "owner": "ipetkov", "repo": "crane", - "rev": "efd36682371678e2b6da3f108fdb5c613b3ec598", - "type": "github" - }, - "original": { - "owner": "ipetkov", - "repo": "crane", - "type": "github" - } - }, - "crane_2": { - "locked": { - "lastModified": 1745454774, - "narHash": "sha256-oLvmxOnsEKGtwczxp/CwhrfmQUG2ym24OMWowcoRhH8=", - "owner": "ipetkov", - "repo": "crane", - "rev": "efd36682371678e2b6da3f108fdb5c613b3ec598", + "rev": "70947c1908108c0c551ddfd73d4f750ff2ea67cd", "type": "github" }, "original": { @@ -164,6 +165,27 @@ "type": "github" } }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1742452566, + "narHash": "sha256-sVuLDQ2UIWfXUBbctzrZrXM2X05YjX08K7XHMztt36E=", + "owner": "nix-community", + "repo": "fenix", + "rev": "7d9ba794daf5e8cc7ee728859bc688d8e26d5f06", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "firefox-darwin": { "inputs": { "nixpkgs": [ @@ -185,6 +207,22 @@ } }, "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { "flake": false, "locked": { "lastModified": 1696426674, @@ -201,6 +239,27 @@ } }, "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "attic", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1741352980, + "narHash": "sha256-+u2UunDA4Cl5Fci3m7S643HzKmIDAe+fiXrLqYsR2fs=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f4330d22f1c5d2ba72d3d22df5597d123fdb60a9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" }, @@ -373,7 +432,7 @@ "mailserver": { "inputs": { "blobs": "blobs", - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_2", "nixpkgs": [ "nixpkgs" ], @@ -395,7 +454,7 @@ }, "niko-nur": { "inputs": { - "flake-parts": "flake-parts", + "flake-parts": "flake-parts_2", "nixpkgs": "nixpkgs" }, "locked": { @@ -428,6 +487,27 @@ "type": "github" } }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "attic", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737420293, + "narHash": "sha256-F1G5ifvqTpJq7fdkT34e/Jy9VCyzd5XfJ9TO8fHhJWE=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "f4158fa080ef4503c8f4c820967d946c2af31ec9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1723603349, @@ -471,6 +551,22 @@ "url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz" } }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1735563628, + "narHash": "sha256-OnSAY7XDSx7CtDoqNh8jwVwh4xNL/2HaJxGjryLWzX8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b134951a4c9f3c995fd7be05f3243f8ecd65d798", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1743259260, @@ -516,6 +612,7 @@ "crane": "crane", "darwin": "darwin", "disko": "disko", + "fenix": "fenix", "firefox-darwin": "firefox-darwin", "helix": "helix", "home-manager": "home-manager", @@ -532,6 +629,23 @@ "zjstatus": "zjstatus" } }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1742296961, + "narHash": "sha256-gCpvEQOrugHWLimD1wTFOJHagnSEP6VYBDspq96Idu0=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "15d87419f1a123d8f888d608129c3ce3ff8f13d4", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, "rust-overlay": { "inputs": { "nixpkgs": [ @@ -703,7 +817,9 @@ }, "zjstatus": { "inputs": { - "crane": "crane_2", + "crane": [ + "crane" + ], "flake-utils": "flake-utils_3", "nixpkgs": [ "nixpkgs" diff --git a/flake.nix b/flake.nix index 4df88d5..ea0a9e0 100644 --- a/flake.nix +++ b/flake.nix @@ -47,6 +47,13 @@ url = "gitlab:famedly/conduit?ref=next"; flake = false; }; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + crane = { + url = "github:ipetkov/crane"; + }; firefox-darwin = { url = "github:bandithedoge/nixpkgs-firefox-darwin"; inputs.nixpkgs.follows = "nixpkgs"; @@ -56,11 +63,10 @@ }; attic = { url = "git+https://git.lix.systems/nrabulinski/attic.git"; - flake = false; - }; - crane = { - url = "github:ipetkov/crane"; - flake = false; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.crane.follows = "crane"; + inputs.lix.follows = "lix"; + inputs.lix-module.follows = "lix-module"; }; helix = { url = "github:helix-editor/helix"; @@ -69,6 +75,7 @@ zjstatus = { url = "github:dj95/zjstatus"; inputs.nixpkgs.follows = "nixpkgs"; + inputs.crane.follows = "crane"; }; lix = { url = "git+https://git.lix.systems/lix-project/lix.git"; diff --git a/hosts/default.nix b/hosts/default.nix index 5f8d069..843a8d1 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -1,7 +1,9 @@ { config, - inputs, }: +let + inputs = builtins.mapAttrs (_: input: input.result) config.inputs; +in { includes = [ ./kazuki diff --git a/inputs.nix b/inputs.nix index 3df77fd..def1e3b 100644 --- a/inputs.nix +++ b/inputs.nix @@ -1,7 +1,6 @@ let lock = builtins.fromJSON (builtins.readFile ./flake.lock); - nodeName = lock.nodes.root.inputs.__flake-compat; - inherit (lock.nodes.${nodeName}.locked) narHash rev url; + inherit (lock.nodes.__flake-compat.locked) narHash rev url; flake-compat = builtins.fetchTarball { url = "${url}/archive/${rev}.tar.gz"; sha256 = narHash; diff --git a/modules/default.nix b/modules/default.nix index 4b28fee..2dc9115 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,8 +1,8 @@ { config, - inputs, }: let + inputs = builtins.mapAttrs (_: input: input.result) config.inputs; perInput = system: flake: { packages = flake.packages.${system}; }; @@ -25,19 +25,12 @@ in inputs.disko.nixosModules.disko inputs.mailserver.nixosModules.default inputs.home-manager.nixosModules.home-manager - "${inputs.attic}/nixos/atticd.nix" + inputs.attic.nixosModules.atticd inputs.lix-module.nixosModules.default { disabledModules = [ "services/networking/atticd.nix" ]; - services.atticd.useFlakeCompatOverlay = false; - nixpkgs.overlays = [ - (final: _: { - attic-client = config.packages.attic-client.result.${final.system}; - attic-server = config.packages.attic-server.result.${final.system}; - }) - ]; } ]; }; diff --git a/modules/nilla/builders/nixpkgs-flake.nix b/modules/nilla/builders/nixpkgs-flake.nix index e0dbcea..4b0115f 100644 --- a/modules/nilla/builders/nixpkgs-flake.nix +++ b/modules/nilla/builders/nixpkgs-flake.nix @@ -1,7 +1,6 @@ { config, lib, - inputs, }: { config.builders.nixpkgs-flake = { @@ -15,7 +14,8 @@ build = pkg: lib.attrs.generate pkg.systems ( - system: inputs.nixpkgs.legacyPackages.${system}.callPackage pkg.package pkg.settings.args + system: + config.inputs.nixpkgs.result.legacyPackages.${system}.callPackage pkg.package pkg.settings.args ); }; } diff --git a/modules/system/flake-qol.nix b/modules/system/flake-qol.nix index d3e2f10..38a5228 100644 --- a/modules/system/flake-qol.nix +++ b/modules/system/flake-qol.nix @@ -7,18 +7,6 @@ }: let cfg = config.settei.flake-qol; - - nixpkgsInputToFlakeRef = - input: - if input._type or "" == "flake" then - { - type = "github"; - owner = "NixOS"; - repo = "nixpkgs"; - inherit (input) lastModified narHash rev; - } - else - input; in { _file = ./flake-qol.nix; @@ -32,12 +20,6 @@ in default = true; }; inputs = mkOption { type = types.unspecified; }; - nixpkgsRef = mkOption { - type = types.unspecified; - default = cfg.inputs.nixpkgs; - apply = - ref: if builtins.isString ref then builtins.parseFlakeRef ref else nixpkgsInputToFlakeRef ref; - }; inputs-flakes = mkOption { type = types.attrs; readOnly = true; @@ -62,8 +44,8 @@ in settei.user.extraArgs = reexportedArgs; nix = { - registry.nixpkgs.to = cfg.nixpkgsRef; - nixPath = [ "nixpkgs=flake:nixpkgs" ]; + registry = lib.mapAttrs (_: flake: { inherit flake; }) cfg.inputs-flakes; + nixPath = lib.mapAttrsToList (name: _: "${name}=flake:${name}") cfg.inputs-flakes; }; }; } diff --git a/nilla.nix b/nilla.nix index 7f3ef71..51b8d63 100644 --- a/nilla.nix +++ b/nilla.nix @@ -18,10 +18,6 @@ inherit src; loader = "raw"; }) inputs; - # Add inputs argument so modules can conveniently use it - config.__module__.args.dynamic.inputs = builtins.mapAttrs ( - _name: input: input.result - ) config.inputs; config.packages = let @@ -47,6 +43,15 @@ getPkgs = system: builtins.mapAttrs (_: pkg: pkg.result.${system}) config.packages; in { + # Re-export for convenience and for caching + attic-client = mkPackageFlakeOutput { + input = "attic"; + output = "attic-client"; + }; + attic-server = mkPackageFlakeOutput { + input = "attic"; + output = "attic-server"; + }; agenix = mkPackageFlakeOutput { input = "agenix"; }; base-packages = mkPackage ( { symlinkJoin, system }: diff --git a/pkgs/conduit/default.nix b/pkgs/conduit/default.nix index 387cf2d..2f1ccdd 100644 --- a/pkgs/conduit/default.nix +++ b/pkgs/conduit/default.nix @@ -1,6 +1,10 @@ { lib, stdenv, + pkgs, + system, + fenix, + crane, src, libiconv, rocksdb, @@ -8,18 +12,27 @@ rustPlatform, }: let - manifest = (builtins.fromTOML (builtins.readFile "${src}/Cargo.toml")).package; + rust = + with fenix.${system}; + combine [ + stable.cargo + stable.rustc + ]; + crane' = (crane pkgs).overrideToolchain rust; + rocksdb' = rocksdb.overrideAttrs ( + final: prev: { + version = "9.1.1"; + src = prev.src.override { + rev = "v${final.version}"; + hash = "sha256-/Xf0bzNJPclH9IP80QNaABfhj4IAR5LycYET18VFCXc="; + }; + } + ); in -rustPlatform.buildRustPackage { - pname = manifest.name; - inherit (manifest) version; - +crane'.buildPackage { inherit src; strictDeps = true; - useFetchCargoVendor = true; - cargoHash = "sha256-wESDxtKRMm/jyCr4kc20UuHGcE2s+OCMjfL+l1XihnA="; - nativeBuildInputs = [ rustPlatform.bindgenHook ]; buildInputs = lib.optionals stdenv.isDarwin [ @@ -29,8 +42,8 @@ rustPlatform.buildRustPackage { ]; # Use system RocksDB - ROCKSDB_INCLUDE_DIR = "${rocksdb}/include"; - ROCKSDB_LIB_DIR = "${rocksdb}/lib"; + ROCKSDB_INCLUDE_DIR = "${rocksdb'}/include"; + ROCKSDB_LIB_DIR = "${rocksdb'}/lib"; NIX_OUTPATH_USED_AS_RANDOM_SEED = "randomseed"; CONDUIT_VERSION_EXTRA = src.shortRev; } diff --git a/pkgs/default.nix b/pkgs/default.nix index 4e5cd0c..f5009d6 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,8 +1,4 @@ -{ - config, - lib, - inputs, -}: +{ config }: let systems = [ "x86_64-linux" @@ -13,21 +9,16 @@ let mkPackage = package: { inherit systems package builder; }; - atticPkgs = lib.attrs.generate systems ( - system: - let - pkgs = inputs.nixpkgs.legacyPackages.${system}.extend inputs.lix-module.overlays.default; - craneLib = import inputs.crane { inherit pkgs; }; - in - pkgs.callPackage "${inputs.attic}/crane.nix" { inherit craneLib; } - ); + in { config.packages.conduit-next = { inherit systems builder; package = import ./conduit; settings.args = { - src = inputs.conduit-src; + src = config.inputs.conduit-src.result; + crane = config.inputs.crane.result.mkLib; + fenix = config.inputs.fenix.result.packages; }; }; @@ -58,15 +49,4 @@ in ''; } ); - - config.packages.attic-client = { - inherit systems; - builder = "custom-load"; - package = { system }: atticPkgs.${system}.attic-client; - }; - config.packages.attic-server = { - inherit systems; - builder = "custom-load"; - package = { system }: atticPkgs.${system}.attic-server; - }; } diff --git a/wrappers/default.nix b/wrappers/default.nix index 89fdb9f..7701749 100644 --- a/wrappers/default.nix +++ b/wrappers/default.nix @@ -1,8 +1,4 @@ -{ - lib, - config, - inputs, -}: +{ lib, config }: let systems = [ "x86_64-linux" @@ -11,8 +7,8 @@ let ]; wrappedPerSystem = lib.attrs.generate systems ( system: - inputs.wrapper-manager-hm-compat.lib { - pkgs = inputs.nixpkgs.legacyPackages.${system}; + config.inputs.wrapper-manager-hm-compat.result.lib { + pkgs = config.inputs.nixpkgs.result.legacyPackages.${system}; modules = [ ./starship ./helix @@ -21,7 +17,7 @@ let ./fish ./wezterm ]; - specialArgs = { inherit inputs; }; + specialArgs.inputs = builtins.mapAttrs (_: input: input.result) config.inputs; } ); wrappedPerSystem' = builtins.mapAttrs (_: wrapped: wrapped.config.build.packages) wrappedPerSystem;