-
-
Notifications
You must be signed in to change notification settings - Fork 10
flake: Remove flake-parts from top-level flake #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,30 +3,28 @@ | |
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
flake-parts.url = "github:hercules-ci/flake-parts"; | ||
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; | ||
treefmt-nix.url = "github:numtide/treefmt-nix"; | ||
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; | ||
nix-github-actions.url = "github:nix-community/nix-github-actions"; | ||
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
|
||
outputs = | ||
inputs@{ flake-parts, nix-github-actions, ... }: | ||
{ | ||
self, | ||
nix-github-actions, | ||
nixpkgs, | ||
treefmt-nix, | ||
... | ||
}: | ||
let | ||
inherit (inputs.nixpkgs) lib; | ||
inherit (inputs) self; | ||
forAllSystems = lib.genAttrs lib.systems.flakeExposed; | ||
inherit (nixpkgs) lib; | ||
|
||
in | ||
flake-parts.lib.mkFlake { inherit inputs; } { | ||
systems = inputs.nixpkgs.lib.systems.flakeExposed; | ||
imports = [ | ||
inputs.flake-parts.flakeModules.modules | ||
inputs.flake-parts.flakeModules.partitions | ||
./lib/modules.nix | ||
./templates/flake-module.nix | ||
]; | ||
{ | ||
|
||
flake.githubActions = nix-github-actions.lib.mkGithubMatrix { | ||
githubActions = nix-github-actions.lib.mkGithubMatrix { | ||
checks = { | ||
x86_64-linux = builtins.removeAttrs (self.packages.x86_64-linux // self.checks.x86_64-linux) [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there actually a better API to this? This will silently ignore conflicts in those two sets. Also |
||
"default" | ||
|
@@ -38,63 +36,75 @@ | |
}; | ||
}; | ||
|
||
flake.lib = import ./lib { inherit lib; }; | ||
lib = import ./lib { inherit lib; }; | ||
|
||
perSystem = | ||
{ | ||
config, | ||
pkgs, | ||
self', | ||
... | ||
}: | ||
templates = { | ||
flake-parts = { | ||
description = "Example flake with nix-unit and flake-parts"; | ||
path = ./templates/flake-parts; | ||
}; | ||
}; | ||
|
||
# TODO: Figure out how to distribute flake-parts without using flake-parts on the top-level | ||
modules = throw "Dunno lol"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how to do this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe something like this?
|
||
|
||
packages = forAllSystems ( | ||
system: | ||
let | ||
inherit (pkgs) stdenv; | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
drvArgs = { | ||
nix = pkgs.nixVersions.nix_2_24; | ||
}; | ||
in | ||
{ | ||
packages.nix-unit = pkgs.callPackage ./default.nix drvArgs; | ||
packages.default = self'.packages.nix-unit; | ||
packages.doc = pkgs.callPackage ./doc { | ||
nix-unit = pkgs.callPackage ./default.nix drvArgs; | ||
default = self.packages.${system}.nix-unit; | ||
doc = pkgs.callPackage ./doc { | ||
inherit self; | ||
}; | ||
devShells.default = | ||
} | ||
); | ||
|
||
formatter = forAllSystems ( | ||
system: | ||
let | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
in | ||
(treefmt-nix.lib.evalModule pkgs ./dev/treefmt.nix).config.build.wrapper | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is still missing |
||
); | ||
|
||
devShells = forAllSystems ( | ||
system: | ||
let | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
inherit (pkgs) stdenv; | ||
drvArgs = { | ||
nix = pkgs.nixVersions.nix_2_24; | ||
}; | ||
in | ||
{ | ||
default = | ||
let | ||
pythonEnv = pkgs.python3.withPackages (_ps: [ ]); | ||
in | ||
pkgs.mkShell { | ||
nativeBuildInputs = self'.packages.nix-unit.nativeBuildInputs ++ [ | ||
nativeBuildInputs = self.packages.${system}.nix-unit.nativeBuildInputs ++ [ | ||
pythonEnv | ||
pkgs.difftastic | ||
pkgs.nixdoc | ||
pkgs.mdbook | ||
pkgs.mdbook-open-on-gh | ||
pkgs.mdbook-cmdrun | ||
config.treefmt.build.wrapper | ||
self.formatter.${system} | ||
]; | ||
inherit (self'.packages.nix-unit) buildInputs; | ||
inherit (self.packages.${system}.nix-unit) buildInputs; | ||
shellHook = lib.optionalString stdenv.isLinux '' | ||
export NIX_DEBUG_INFO_DIRS="${pkgs.curl.debug}/lib/debug:${drvArgs.nix.debug}/lib/debug''${NIX_DEBUG_INFO_DIRS:+:$NIX_DEBUG_INFO_DIRS}" | ||
export NIX_UNIT_OUTPATH=${self} | ||
''; | ||
}; | ||
}; | ||
} | ||
); | ||
|
||
# Extra things to load only when accessing development-specific attributes | ||
# such as `checks` | ||
partitionedAttrs.checks = "dev"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing this line disconnects the check derivation for the flake-parts module. Considering that subflakes still are still quite broken until the next NixOS release, it still has to be wired through (I guess that's a partial answer to your question about the added value here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
where can I find out about the upcoming improvements? Thanks! |
||
partitionedAttrs.devShells = "dev"; | ||
partitionedAttrs.tests = "dev"; # lib/modules/flake/dogfood.nix | ||
partitions.dev.module = { | ||
imports = [ | ||
inputs.treefmt-nix.flakeModule | ||
self.modules.flake.default | ||
./lib/modules/flake/dogfood.nix | ||
]; | ||
perSystem = { | ||
treefmt.imports = [ ./dev/treefmt.nix ]; | ||
}; | ||
}; | ||
}; | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of removing flake-parts, or in addition to removing it, you could gain some fetching (or really, locking) efficiency by moving these two over to the
dev
partition instead.