flake: partition dev inputs (#1289)

Link: https://github.com/nix-community/stylix/pull/1289

Reviewed-by: Daniel Thwaites <danth@danth.me>
Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Tested-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
This commit is contained in:
awwpotato 2025-07-06 14:56:44 -07:00 committed by GitHub
parent a294d8b2a3
commit a5c1532ab8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 373 additions and 219 deletions

View file

@ -41,22 +41,40 @@ jobs:
email "$id+$name@users.noreply.github.com" \
>>"$GITHUB_OUTPUT"
- uses: DeterminateSystems/update-flake-lock@v26
with:
token: ${{ steps.generate-token.outputs.token }}
git-committer-name: ${{ steps.user-info.outputs.name }}
git-committer-email: ${{ steps.user-info.outputs.email }}
git-author-name: ${{ steps.user-info.outputs.name }}
git-author-email: ${{ steps.user-info.outputs.email }}
branch: update_flake_lock_action_${{ matrix.branch }}
commit-msg: "flake: update all inputs"
pr-title: "${{ startsWith(matrix.branch, 'release') && format('[{0}] ', matrix.branch) || '' }}stylix: update all flake inputs" # yamllint disable-line rule:line-length
pr-labels: "topic: dependencies"
pr-body: >
Automated changes by the
[update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock)
GitHub Action.
- name: setup git
env:
name: ${{ steps.user-info.outputs.name }}
email: ${{ steps.user-info.outputs.email }}
run: |
git config --global user.name "$name"
git config --global user.email "$email"
```
{{ env.GIT_COMMIT_MESSAGE }}
```
- name: update lock files
run: |
nix flake update \
--commit-lock-file \
--option commit-lock-file-summary "flake: update root inputs"
nix flake update \
--commit-lock-file \
--flake ./flake/dev \
--option commit-lock-file-summary "flake: update dev inputs"
- name: create pull request
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
base_branch: ${{ matrix.branch }}
pr_branch: update_flake_lock_action_${{ matrix.branch }}
title: "${{ startsWith(matrix.branch, 'release') && format('[{0}] ', matrix.branch) || '' }}flake: update public and dev inputs" # yamllint disable-line rule:line-length
run: |
git switch --create "$pr_branch"
git push origin "$pr_branch" \
--force \
--set-upstream
gh pr create \
--base "$base_branch" \
--title "$title" \
--label "topic: dependencies" ||
echo "Failed to create PR"

View file

@ -1,7 +1,7 @@
(import (
let
inherit (lock.nodes.flake-compat.locked) narHash rev;
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
lock = builtins.fromJSON (builtins.readFile ./flake/dev/flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${rev}.tar.gz";

83
flake.lock generated
View file

@ -83,21 +83,6 @@
"type": "github"
}
},
"flake-compat": {
"locked": {
"lastModified": 1747046372,
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
@ -134,51 +119,6 @@
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": [
"flake-compat"
],
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1747372754,
"narHash": "sha256-2Y53NGIX2vxfie1rOW0Qb86vjRZ7ngizoo+bnXU9D9k=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "80479b6ec16fefd9c1db3ea13aeb038c60530f46",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"gnome-shell": {
"flake": false,
"locked": {
@ -196,26 +136,6 @@
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1751146119,
"narHash": "sha256-gvjG95TCnUVJkvQvLMlnC4NqiqFyBdJk3o8/RwuHeaU=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "76d0c31fce2aa0c71409de953e2f9113acd5b656",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1748460289,
@ -263,11 +183,8 @@
"base16-helix": "base16-helix",
"base16-vim": "base16-vim",
"firefox-gnome-theme": "firefox-gnome-theme",
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"git-hooks": "git-hooks",
"gnome-shell": "gnome-shell",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs",
"nur": "nur",
"systems": "systems",

View file

@ -41,16 +41,6 @@
flake = false;
};
flake-compat.url = "github:edolstra/flake-compat";
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs = {
flake-compat.follows = "flake-compat";
nixpkgs.follows = "nixpkgs";
};
};
gnome-shell = {
# TODO: Unlocking the input and pointing to official repository requires
# updating the patch:
@ -59,12 +49,6 @@
flake = false;
};
# The 'home-manager' input is used to generate the documentation.
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nur = {
url = "github:nix-community/NUR";
inputs = {

View file

@ -1,86 +1,21 @@
{ inputs, lib, ... }:
{
imports = [
inputs.flake-parts.flakeModules.partitions
./deprecation
./dev-shell.nix
./modules.nix
./packages.nix
./pre-commit.nix
./propagated-packages.nix
];
perSystem =
{ pkgs, ... }:
{
# TODO: consider using https://flake.parts/options/treefmt-nix.html once
# dev flake is partitioned
formatter = pkgs.treefmt.withConfig {
runtimeInputs = with pkgs; [
# keep-sorted start
biome
keep-sorted
nixfmt-rfc-style
ruff
stylish-haskell
# keep-sorted end
];
partitions.dev = {
module = ./dev;
extraInputsFlake = ./dev;
};
settings = {
on-unmatched = "info";
tree-root-file = "flake.nix";
formatter = {
# keep-sorted start block=yes
biome = {
command = "biome";
options = [
"format"
"--write"
"--no-errors-on-unmatched"
"--config-path"
(pkgs.writers.writeJSON "biome.json" {
formatter = {
indentStyle = "space";
indentWidth = 2;
lineWidth = 80;
};
})
];
includes = [
"*.css"
"*.js"
"*.json"
];
excludes = [
# Contains custom syntax that biome can't handle
"modules/swaync/base.css"
];
};
keep-sorted = {
command = "keep-sorted";
includes = [ "*" ];
};
nixfmt = {
command = "nixfmt";
options = [ "--width=80" ];
includes = [ "*.nix" ];
};
ruff = {
command = "ruff";
options = [
"--config"
(pkgs.writers.writeTOML "ruff.toml" {
line-length = 80;
})
"format"
];
includes = [ "*.py" ];
};
stylish-haskell = {
command = "stylish-haskell";
includes = [ "*.hx" ];
};
# keep-sorted end
};
};
};
};
partitionedAttrs = lib.genAttrs [
"checks"
"devShells"
"formatter"
] (_: "dev");
}

84
flake/dev/default.nix Normal file
View file

@ -0,0 +1,84 @@
{
imports = [
./dev-shell.nix
./nixpkgs-and-dev-nixpkgs-version-consistency.nix
./packages.nix
./pre-commit.nix
];
perSystem =
{ pkgs, ... }:
{
# TODO: consider using https://flake.parts/options/treefmt-nix.html
formatter = pkgs.treefmt.withConfig {
runtimeInputs = with pkgs; [
# keep-sorted start
biome
keep-sorted
nixfmt-rfc-style
ruff
stylish-haskell
# keep-sorted end
];
settings = {
on-unmatched = "info";
tree-root-file = "flake.nix";
formatter = {
# keep-sorted start block=yes
biome = {
command = "biome";
options = [
"format"
"--write"
"--no-errors-on-unmatched"
"--config-path"
(pkgs.writers.writeJSON "biome.json" {
formatter = {
indentStyle = "space";
indentWidth = 2;
lineWidth = 80;
};
})
];
includes = [
"*.css"
"*.js"
"*.json"
];
excludes = [
# Contains custom syntax that biome can't handle
"modules/swaync/base.css"
];
};
keep-sorted = {
command = "keep-sorted";
includes = [ "*" ];
};
nixfmt = {
command = "nixfmt";
options = [ "--width=80" ];
includes = [ "*.nix" ];
};
ruff = {
command = "ruff";
options = [
"--config"
(pkgs.writers.writeTOML "ruff.toml" {
line-length = 80;
})
"format"
];
includes = [ "*.py" ];
};
stylish-haskell = {
command = "stylish-haskell";
includes = [ "*.hx" ];
};
# keep-sorted end
};
};
};
};
}

110
flake/dev/flake.lock generated Normal file
View file

@ -0,0 +1,110 @@
{
"nodes": {
"dev-nixpkgs": {
"locked": {
"lastModified": 1748460289,
"narHash": "sha256-7doLyJBzCllvqX4gszYtmZUToxKvMUrg45EUWaUYmBg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "96ec055edbe5ee227f28cdbc3f1ddf1df5965102",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"flake-compat": {
"locked": {
"lastModified": 1747046372,
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": [
"flake-compat"
],
"gitignore": "gitignore",
"nixpkgs": [
"dev-nixpkgs"
]
},
"locked": {
"lastModified": 1747372754,
"narHash": "sha256-2Y53NGIX2vxfie1rOW0Qb86vjRZ7ngizoo+bnXU9D9k=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "80479b6ec16fefd9c1db3ea13aeb038c60530f46",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"dev-nixpkgs"
]
},
"locked": {
"lastModified": 1751146119,
"narHash": "sha256-gvjG95TCnUVJkvQvLMlnC4NqiqFyBdJk3o8/RwuHeaU=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "76d0c31fce2aa0c71409de953e2f9113acd5b656",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"root": {
"inputs": {
"dev-nixpkgs": "dev-nixpkgs",
"flake-compat": "flake-compat",
"git-hooks": "git-hooks",
"home-manager": "home-manager"
}
}
},
"root": "root",
"version": 7
}

54
flake/dev/flake.nix Normal file
View file

@ -0,0 +1,54 @@
{
description = ''
Private inputs for development purposes. These are used by the top level
flake in the `dev` partition, but do not appear in consumers' lock files.
'';
inputs = {
# We need to define a nixpkgs input so that other inputs can follow it.
# It is prefixed with 'dev-' to avoid shadowing the public flake's
# 'nixpkgs' input, which could affect local testing with --override-input.
#
# TODO: Replace
#
# dev-nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
#
# with
#
# dev-nixpkgs = {
# url = "path:../..";
# inputs = {
# "<PUBLIC_INPUT_1>".follows = "";
# "<PUBLIC_INPUT_2>".follows = "";
# "<PUBLIC_INPUT_3>".follows = "";
# };
# };
#
# once 26.05 is released, giving non-flake end-users and Stylix
# contributors two LTS releases to adopt Nix 2.26+ [1]. Note that
# non-nixpkgs public flake inputs should be disabled.
#
# [1]: https://github.com/NixOS/nix/blob/d4f67fd46dfe2bc950bdfa14273f87b8a4c32e47/doc/manual/source/release-notes/rl-2.26.md?plain=1#L3-L11
dev-nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# keep-sorted start block=yes newline_separated=yes
flake-compat.url = "github:edolstra/flake-compat";
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs = {
flake-compat.follows = "flake-compat";
nixpkgs.follows = "dev-nixpkgs";
};
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "dev-nixpkgs";
};
# keep-sorted end
};
# This flake is only used for its inputs.
outputs = _: { };
}

View file

@ -0,0 +1,24 @@
{ inputs, ... }:
{
perSystem =
{ pkgs, ... }:
{
checks.nixpkgs-and-dev-nixpkgs-version-consistency =
pkgs.runCommand "nixpkgs-and-dev-nixpkgs-version-consistency"
{
dev_nixpkgs = inputs.dev-nixpkgs.narHash;
nixpkgs = inputs.nixpkgs.narHash;
}
''
if [ "$nixpkgs" != "$dev_nixpkgs" ]; then
printf \
'inconsistent nixpkgs (%s) and dev-nixpkgs (%s) versions\n' \
"$nixpkgs" \
"$dev_nixpkgs" \
>&2
exit 1
fi
mkdir "$out"
'';
};
}

18
flake/dev/packages.nix Normal file
View file

@ -0,0 +1,18 @@
{ lib, inputs, ... }:
{
perSystem =
{ pkgs, config, ... }:
{
# Build all packages with 'nix flake check' instead of only verifying they
# are derivations.
checks = config.packages;
# Testbeds are virtual machines based on NixOS, therefore they are
# only available for Linux systems.
packages = lib.mkIf pkgs.stdenv.hostPlatform.isLinux (
import ../../stylix/testbed/default.nix {
inherit pkgs inputs lib;
}
);
};
}

View file

@ -1,33 +1,19 @@
{ lib, inputs, ... }:
{ inputs, ... }:
{
perSystem =
{ pkgs, config, ... }:
{
# Build all packages with 'nix flake check' instead of only verifying they
# are derivations.
checks = config.packages;
# Make 'nix run .#doc' serve the documentation site
apps.doc.program = config.packages.serve-docs;
packages = lib.mkMerge [
# Testbeds are virtual machines based on NixOS, therefore they are
# only available for Linux systems.
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux (
import ../stylix/testbed {
inherit pkgs inputs lib;
}
))
{
doc = pkgs.callPackage ../doc {
inherit (inputs) self;
};
serve-docs = pkgs.callPackage ../doc/server.nix {
inherit (config.packages) doc;
};
palette-generator = pkgs.callPackage ../palette-generator { };
}
];
packages = {
doc = pkgs.callPackage ../doc {
inherit (inputs) self;
};
serve-docs = pkgs.callPackage ../doc/server.nix {
inherit (config.packages) doc;
};
palette-generator = pkgs.callPackage ../palette-generator { };
};
};
}

View file

@ -0,0 +1,24 @@
{
lib,
config,
partitionStack,
...
}:
{
# For any output attrs normally defined by the public flake configuration,
# any exceptions must be manually propagated from the `dev` partition.
#
# NOTE: Attrs should be explicitly propagated at the deepest level.
# Otherwise the partition won't be lazy, making it pointless.
# E.g. propagate `packages.${system}.foo` instead of `packages.${system}`
# See: https://github.com/hercules-ci/flake-parts/issues/258
perSystem =
{ pkgs, system, ... }:
lib.optionalAttrs (partitionStack == [ ]) {
packages = lib.mkIf pkgs.stdenv.hostPlatform.isLinux (
lib.mapAttrs (
name: _: config.partitions.dev.module.flake.packages.${system}.${name}
) (import ../stylix/testbed/autoload.nix { inherit lib pkgs; })
);
};
}