difftreelog
refactor move definitions around
in: trunk
32 files changed
flake.lockdiffbeforeafterboth66 "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz"66 "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz"67 }67 }68 },68 },69 "nixpkgs-stable-for-tests": {70 "locked": {71 "lastModified": 1721548954,72 "narHash": "sha256-7cCC8+Tdq1+3OPyc3+gVo9dzUNkNIQfwSDJ2HSi2u3o=",73 "owner": "nixos",74 "repo": "nixpkgs",75 "rev": "63d37ccd2d178d54e7fb691d7ec76000740ea24a",76 "type": "github"77 },78 "original": {79 "owner": "nixos",80 "ref": "nixos-24.05",81 "repo": "nixpkgs",82 "type": "github"83 }84 },85 "root": {69 "root": {86 "inputs": {70 "inputs": {87 "crane": "crane",71 "crane": "crane",88 "flake-parts": "flake-parts",72 "flake-parts": "flake-parts",89 "nixpkgs": "nixpkgs",73 "nixpkgs": "nixpkgs",90 "nixpkgs-stable-for-tests": "nixpkgs-stable-for-tests",91 "rust-overlay": "rust-overlay"74 "rust-overlay": "rust-overlay"92 }75 }93 },76 },flake.nixdiffbeforeafterboth334 inputs = {4 inputs = {5 nixpkgs.url = "github:nixos/nixpkgs/master";5 nixpkgs.url = "github:nixos/nixpkgs/master";6 nixpkgs-stable-for-tests.url = "github:nixos/nixpkgs/nixos-24.05";7 rust-overlay = {6 rust-overlay = {8 url = "github:oxalica/rust-overlay";7 url = "github:oxalica/rust-overlay";9 inputs = {8 inputs = {33 // {32 // {34 fleetConfiguration = throw "function-based interface is deprecated, use flake-parts syntax instead";33 fleetConfiguration = throw "function-based interface is deprecated, use flake-parts syntax instead";35 };34 };36 flakeModules.default = (import ./lib/flakePart.nix {35 flakeModules.default = import ./lib/flakePart.nix {37 inherit crane;36 inherit crane;38 });37 };39 flakeModule = flakeModules.default;38 flakeModule = flakeModules.default;403941 # To be used with https://github.com/NixOS/nix/pull/889240 # To be used with https://github.com/NixOS/nix/pull/889292 };91 };93 # Reference fleet package should be built with nightly rust, specified in rust-toolchain.toml.92 # Reference fleet package should be built with nightly rust, specified in rust-toolchain.toml.94 packages = lib.mkIf deployerSystem (let93 packages = lib.mkIf deployerSystem (let95 packages = import ./pkgs {94 packages = pkgs.callPackages ./pkgs {96 inherit (pkgs) callPackage;97 inherit craneLib;95 inherit craneLib;98 };96 };99 in97 in121 # fleet-install-secrets will not be built normally, because they are not ran directly by user most of the time.119 # fleet-install-secrets will not be built normally, because they are not ran directly by user most of the time.122 # checks there build packages for default nixpkgs rustPlatform packages.120 # checks there build packages for default nixpkgs rustPlatform packages.123 checks = let121 checks = let124 packages = import ./pkgs {122 packages = pkgs.callPackages ./pkgs {};125 inherit (pkgs) callPackage;126 craneLib = crane.mkLib pkgs;127 };128 packages-with-nixpkgs-stable = import ./pkgs {129 inherit (pkgs) callPackage;130 craneLib = crane.mkLib (import inputs.nixpkgs-stable-for-tests {inherit system;});131 };132 prefixAttrs = prefix: attrs:123 prefixAttrs = prefix: attrs:133 mapAttrs' (name: value: {124 mapAttrs' (name: value: {134 name = "${prefix}${name}";125 name = "${prefix}${name}";140 in131 in141 # `fleet` crate wants nightly rust, also little sense of supporting it on stable nixpkgs.132 # `fleet` crate wants nightly rust, also little sense of supporting it on stable nixpkgs.142 (prefixAttrs "nixpkgs-" (removeAttrs packages ["fleet"]))133 (prefixAttrs "nixpkgs-" (removeAttrs packages ["fleet"]));143 // (prefixAttrs "nixpkgs-stable-" (removeAttrs packages-with-nixpkgs-stable ["fleet"]));144 formatter = pkgs.alejandra;134 formatter = pkgs.alejandra;145 };135 };146 };136 };lib/default.nixdiffbeforeafterboth4 inherit (lib.options) mkOption mergeOneOption;4 inherit (lib.options) mkOption mergeOneOption;5 inherit (lib.modules) mkOverride;5 inherit (lib.modules) mkOverride;6 inherit (lib.types) listOf submodule attrsOf mkOptionType;6 inherit (lib.types) listOf submodule attrsOf mkOptionType;7 inherit (lib.strings) optionalString;7 inherit (lib.strings) optionalString hasPrefix removePrefix;8in rec {8in rec {9 types = {9 types = {10 overlay = mkOptionType {10 overlay = mkOptionType {16 listOfOverlay = listOf types.overlay;16 listOfOverlay = listOf types.overlay;171718 mkHostsType = module: attrsOf (submodule module);18 mkHostsType = module: attrsOf (submodule module);19 mkDataType = module: submodule module;19 };20 };202121 options = {22 options = {22 mkHostsOption = module:23 mkHostsOption = module:23 mkOption {24 mkOption {24 type = types.mkHostsType module;25 type = types.mkHostsType module;25 };26 };27 mkDataOption = module:28 mkOption {29 type = types.mkDataType module;30 };26 };31 };273228 inherit (options) mkHostsOption;33 inherit (options) mkHostsOption;119124120 inherit (secrets) mkPassword mkEd25519 mkX25519 mkRsa mkBytes mkHexBytes mkBase64Bytes;125 inherit (secrets) mkPassword mkEd25519 mkX25519 mkRsa mkBytes mkHexBytes mkBase64Bytes;126127 strings = let128 plaintextPrefix = "<PLAINTEXT>";129 plaintextNewlinePrefix = "<PLAINTEXT-NL>";130 in {131 decodeRawSecret = raw:132 if hasPrefix plaintextPrefix raw133 then removePrefix plaintextPrefix raw134 else if hasPrefix plaintextNewlinePrefix raw135 then removePrefix plaintextNewlinePrefix raw136 else throw "decodeRawSecret only works with plaintext-encoded secret public parts, got ${raw}";137 };138139 inherit (strings) decodeRawSecret;121}140}122141lib/flakePart.nixdiffbeforeafterboth7 inherit (lib.options) mkOption;7 inherit (lib.options) mkOption;8 inherit (lib.attrsets) mapAttrs;8 inherit (lib.attrsets) mapAttrs;9 inherit (lib.types) lazyAttrsOf deferredModule unspecified;9 inherit (lib.types) lazyAttrsOf deferredModule unspecified;10 inherit (lib.strings) isPath;10 inherit (fleetLib.options) mkHostsOption;11 inherit (fleetLib.options) mkHostsOption;11in {12in {12 options.fleetModules = mkOption {13 options.fleetModules = mkOption {36 bootstrapNixpkgs = bootstrapEval.config.nixpkgs.buildUsing;37 bootstrapNixpkgs = bootstrapEval.config.nixpkgs.buildUsing;37 normalEval = bootstrapNixpkgs.lib.evalModules {38 normalEval = bootstrapNixpkgs.lib.evalModules {38 modules =39 modules =39 (import ../modules/fleet/_modules.nix)40 (import ../modules/module-list.nix)40 ++ [41 ++ [41 data42 module42 module43 {43 {44 options.hosts = mkHostsOption {44 options.hosts = mkHostsOption {45 nixos.nixpkgs.overlays = [45 nixos.nixpkgs.overlays = [46 (final: prev: {46 (final: prev:47 # FIXME: make this name not conflicting47 import ../pkgs {48 inherit (prev) callPackage;48 craneLib = crane.mkLib prev;49 craneLib = crane.mkLib prev;49 })50 })50 ];51 ];51 };52 };53 config = {54 data =55 if isPath data56 then import data57 else data;58 };52 }59 }53 ];60 ];54 specialArgs.fleetLib = import ../lib {61 specialArgs.fleetLib = import ../lib {modules/assertions.nixdiffbeforeafterbothno changes
modules/fleet/_modules.nixdiffbeforeafterbothno changes
modules/fleet/assertions.nixdiffbeforeafterbothno changes
modules/fleet/fleetLib.nixdiffbeforeafterbothno changes
modules/fleet/hosts.nixdiffbeforeafterbothno changes
modules/fleet/meta.nixdiffbeforeafterbothno changes
modules/fleet/nixos.nixdiffbeforeafterbothno changes
modules/fleet/nixpkgs.nixdiffbeforeafterbothno changes
modules/fleet/secrets.nixdiffbeforeafterbothno changes
modules/fleetLib.nixdiffbeforeafterbothno changes
modules/hosts.nixdiffbeforeafterbothno changes
modules/meta.nixdiffbeforeafterbothno changes
modules/module-list.nixdiffbeforeafterbothno changes
modules/nixos.nixdiffbeforeafterbothno changes
modules/nixos/meta.nixdiffbeforeafterbothno changes
modules/nixos/module-list.nixdiffbeforeafterbothno changes
modules/nixos/nix-sign.nixdiffbeforeafterbothno changes
modules/nixos/rollback.nixdiffbeforeafterbothno changes
modules/nixos/secrets.nixdiffbeforeafterbothno changes
modules/nixpkgs.nixdiffbeforeafterbothno changes
modules/secrets-data.nixdiffbeforeafterbothno changes
modules/secrets.nixdiffbeforeafterbothno changes
nixos/assertions.nixdiffbeforeafterbothno changes
nixos/meta.nixdiffbeforeafterbothno changes
nixos/modules/module-list.nixdiffbeforeafterbothno changes
nixos/nix-sign.nixdiffbeforeafterbothno changes
nixos/rollback.nixdiffbeforeafterbothno changes
nixos/secrets.nixdiffbeforeafterbothno changes