diff --git a/flake.lock b/flake.lock index 32a92b1..14086e8 100644 --- a/flake.lock +++ b/flake.lock @@ -44,24 +44,7 @@ } }, "attic": { - "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" - }, + "flake": false, "locked": { "lastModified": 1742679462, "narHash": "sha256-L9q9KDqiJEREM/GRnSo4vB9VCvclmdRT9vXuFwBmb9Y=", @@ -110,12 +93,28 @@ } }, "crane": { + "flake": false, "locked": { - "lastModified": 1742394900, - "narHash": "sha256-vVOAp9ahvnU+fQoKd4SEXB2JG2wbENkpqcwlkIXgUC0=", + "lastModified": 1745454774, + "narHash": "sha256-oLvmxOnsEKGtwczxp/CwhrfmQUG2ym24OMWowcoRhH8=", "owner": "ipetkov", "repo": "crane", - "rev": "70947c1908108c0c551ddfd73d4f750ff2ea67cd", + "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", "type": "github" }, "original": { @@ -165,27 +164,6 @@ "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": [ @@ -207,22 +185,6 @@ } }, "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, @@ -239,27 +201,6 @@ } }, "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" }, @@ -432,7 +373,7 @@ "mailserver": { "inputs": { "blobs": "blobs", - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat", "nixpkgs": [ "nixpkgs" ], @@ -454,7 +395,7 @@ }, "niko-nur": { "inputs": { - "flake-parts": "flake-parts_2", + "flake-parts": "flake-parts", "nixpkgs": "nixpkgs" }, "locked": { @@ -487,27 +428,6 @@ "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, @@ -551,22 +471,6 @@ "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, @@ -612,7 +516,6 @@ "crane": "crane", "darwin": "darwin", "disko": "disko", - "fenix": "fenix", "firefox-darwin": "firefox-darwin", "helix": "helix", "home-manager": "home-manager", @@ -629,23 +532,6 @@ "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": [ @@ -817,9 +703,7 @@ }, "zjstatus": { "inputs": { - "crane": [ - "crane" - ], + "crane": "crane_2", "flake-utils": "flake-utils_3", "nixpkgs": [ "nixpkgs" diff --git a/flake.nix b/flake.nix index ea0a9e0..4df88d5 100644 --- a/flake.nix +++ b/flake.nix @@ -47,13 +47,6 @@ 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"; @@ -63,10 +56,11 @@ }; attic = { url = "git+https://git.lix.systems/nrabulinski/attic.git"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.crane.follows = "crane"; - inputs.lix.follows = "lix"; - inputs.lix-module.follows = "lix-module"; + flake = false; + }; + crane = { + url = "github:ipetkov/crane"; + flake = false; }; helix = { url = "github:helix-editor/helix"; @@ -75,7 +69,6 @@ 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 843a8d1..5f8d069 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -1,9 +1,7 @@ { config, + inputs, }: -let - inputs = builtins.mapAttrs (_: input: input.result) config.inputs; -in { includes = [ ./kazuki diff --git a/inputs.nix b/inputs.nix index def1e3b..3df77fd 100644 --- a/inputs.nix +++ b/inputs.nix @@ -1,6 +1,7 @@ let lock = builtins.fromJSON (builtins.readFile ./flake.lock); - inherit (lock.nodes.__flake-compat.locked) narHash rev url; + nodeName = lock.nodes.root.inputs.__flake-compat; + inherit (lock.nodes.${nodeName}.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 2dc9115..4b28fee 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,12 +25,19 @@ in inputs.disko.nixosModules.disko inputs.mailserver.nixosModules.default inputs.home-manager.nixosModules.home-manager - inputs.attic.nixosModules.atticd + "${inputs.attic}/nixos/atticd.nix" 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 4b0115f..e0dbcea 100644 --- a/modules/nilla/builders/nixpkgs-flake.nix +++ b/modules/nilla/builders/nixpkgs-flake.nix @@ -1,6 +1,7 @@ { config, lib, + inputs, }: { config.builders.nixpkgs-flake = { @@ -14,8 +15,7 @@ build = pkg: lib.attrs.generate pkg.systems ( - system: - config.inputs.nixpkgs.result.legacyPackages.${system}.callPackage pkg.package pkg.settings.args + system: inputs.nixpkgs.legacyPackages.${system}.callPackage pkg.package pkg.settings.args ); }; } diff --git a/modules/system/flake-qol.nix b/modules/system/flake-qol.nix index 38a5228..d3e2f10 100644 --- a/modules/system/flake-qol.nix +++ b/modules/system/flake-qol.nix @@ -7,6 +7,18 @@ }: 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; @@ -20,6 +32,12 @@ 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; @@ -44,8 +62,8 @@ in settei.user.extraArgs = reexportedArgs; nix = { - registry = lib.mapAttrs (_: flake: { inherit flake; }) cfg.inputs-flakes; - nixPath = lib.mapAttrsToList (name: _: "${name}=flake:${name}") cfg.inputs-flakes; + registry.nixpkgs.to = cfg.nixpkgsRef; + nixPath = [ "nixpkgs=flake:nixpkgs" ]; }; }; } diff --git a/nilla.nix b/nilla.nix index 51b8d63..7f3ef71 100644 --- a/nilla.nix +++ b/nilla.nix @@ -18,6 +18,10 @@ 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 @@ -43,15 +47,6 @@ 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 2f1ccdd..387cf2d 100644 --- a/pkgs/conduit/default.nix +++ b/pkgs/conduit/default.nix @@ -1,10 +1,6 @@ { lib, stdenv, - pkgs, - system, - fenix, - crane, src, libiconv, rocksdb, @@ -12,27 +8,18 @@ rustPlatform, }: let - 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="; - }; - } - ); + manifest = (builtins.fromTOML (builtins.readFile "${src}/Cargo.toml")).package; in -crane'.buildPackage { +rustPlatform.buildRustPackage { + pname = manifest.name; + inherit (manifest) version; + inherit src; strictDeps = true; + useFetchCargoVendor = true; + cargoHash = "sha256-wESDxtKRMm/jyCr4kc20UuHGcE2s+OCMjfL+l1XihnA="; + nativeBuildInputs = [ rustPlatform.bindgenHook ]; buildInputs = lib.optionals stdenv.isDarwin [ @@ -42,8 +29,8 @@ crane'.buildPackage { ]; # 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 f5009d6..4e5cd0c 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,4 +1,8 @@ -{ config }: +{ + config, + lib, + inputs, +}: let systems = [ "x86_64-linux" @@ -9,16 +13,21 @@ 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 = config.inputs.conduit-src.result; - crane = config.inputs.crane.result.mkLib; - fenix = config.inputs.fenix.result.packages; + src = inputs.conduit-src; }; }; @@ -49,4 +58,15 @@ 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 7701749..89fdb9f 100644 --- a/wrappers/default.nix +++ b/wrappers/default.nix @@ -1,4 +1,8 @@ -{ lib, config }: +{ + lib, + config, + inputs, +}: let systems = [ "x86_64-linux" @@ -7,8 +11,8 @@ let ]; wrappedPerSystem = lib.attrs.generate systems ( system: - config.inputs.wrapper-manager-hm-compat.result.lib { - pkgs = config.inputs.nixpkgs.result.legacyPackages.${system}; + inputs.wrapper-manager-hm-compat.lib { + pkgs = inputs.nixpkgs.legacyPackages.${system}; modules = [ ./starship ./helix @@ -17,7 +21,7 @@ let ./fish ./wezterm ]; - specialArgs.inputs = builtins.mapAttrs (_: input: input.result) config.inputs; + specialArgs = { inherit inputs; }; } ); wrappedPerSystem' = builtins.mapAttrs (_: wrapped: wrapped.config.build.packages) wrappedPerSystem;