Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/server.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
docs,
doc,
http-server,
writeShellApplication,
}:
Expand All @@ -17,6 +17,6 @@ writeShellApplication {
"-o"
];
text = ''
http-server ${docs} "''${server_flags[@]}"
http-server ${doc} "''${server_flags[@]}"
'';
}
2 changes: 1 addition & 1 deletion flake/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
imports = [
./deprecated.nix
./deprecation
./dev-shell.nix
./modules.nix
./packages.nix
Expand Down
21 changes: 20 additions & 1 deletion flake/deprecated.nix → flake/deprecation/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
...
}:
{
imports = [
./per-system-option.nix
];

# NOTE: the `flake` submodule has a `lazyAttrsOf` freeform type.
#
# This means a `mkIf false` definition will not omit the attr, because
Expand All @@ -14,6 +18,21 @@

# Drop this alias after 26.05
flake = lib.mkIf (!lib.oldestSupportedReleaseIsAtLeast 2605) {
homeManagerModules = builtins.warn "stylix: flake output `homeManagerModules` has been renamed to `homeModules`" self.homeModules;
homeManagerModules = builtins.warn "stylix: flake output `homeManagerModules` has been renamed to `homeModules` and will be removed after 26.05." self.homeModules;
};

perSystem.stylix.aliases = [
{
output = "apps";
old = "docs";
new = "doc";
until = 2511;
}
{
output = "packages";
old = "docs";
new = "doc";
until = 2511;
}
];
}
86 changes: 86 additions & 0 deletions flake/deprecation/per-system-option.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{ lib, config, ... }:
{
perSystem.options.stylix.aliases = lib.mkOption {
type = lib.types.listOf (
lib.types.submodule {
options = {
output = lib.mkOption {
type = lib.types.str;
description = ''
The per-system attribute in which to define the alias.
'';
};
old = lib.mkOption {
type = lib.types.str;
description = "The name of the alias.";
};
new = lib.mkOption {
type = lib.types.str;
description = "The name of the alias target.";
};
since = lib.mkOption {
type = with lib.types; nullOr ints.unsigned;
default = null;
description = ''
Warn only once the specified release is the oldest supported
nixpkgs release.

If `null`, the alias will always warn.
'';
};
until = lib.mkOption {
type = lib.types.ints.unsigned;
description = ''
Create the alias only until the specified release is the oldest
supported nixpkgs release.

The alias spec can be safely removed after this release.
'';
};
};
}
);
default = [ ];
description = "A list of per-system aliases.";
};

# Transpose per-system aliases to the top-level
flake = lib.mkMerge (
lib.mapAttrsToList (
system: cfg:
let
# Produces config definition for an alias
mkAlias =
{
output,
since,
until,
old,
new,
}:
let
paths = builtins.mapAttrs (_: attr: [
output
system
attr
]) { inherit old new; };
names = builtins.mapAttrs (_: lib.showAttrPath) paths // {
until = lib.pipe until [
builtins.toString
(builtins.match "([[:digit:]]{2})([[:digit:]]{2})")
(lib.concatStringsSep ".")
];
};
in
lib.mkIf (!lib.oldestSupportedReleaseIsAtLeast until) (
lib.attrsets.setAttrByPath paths.old (
lib.warnIf (since != null -> lib.oldestSupportedReleaseIsAtLeast since)
"stylix: flake output `${names.old}` has been renamed to `${names.new}` and will be removed after ${names.until}."
(cfg.${output}.${new} or (throw "stylix: flake alias not found: ${names.new}"))
)
);
in
lib.mkMerge (map mkAlias cfg.stylix.aliases)
) config.allSystems
);
}
2 changes: 1 addition & 1 deletion flake/dev-shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# not the local flake worktree that has possibly been modified since
# entering the devshell.
build-and-run-docs = pkgs.writeShellScriptBin "serve-docs" ''
nix run .#docs
nix run .#doc
'';
in
{
Expand Down
6 changes: 3 additions & 3 deletions flake/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
checks = config.packages;

# Make 'nix run .#docs' serve the docs
apps.docs.program = config.packages.serve-docs;
apps.doc.program = config.packages.serve-docs;

packages = lib.mkMerge [
# Testbeds are virtual machines based on NixOS, therefore they are
Expand All @@ -20,13 +20,13 @@
}
))
{
docs = pkgs.callPackage ../doc {
doc = pkgs.callPackage ../doc {
inherit inputs;
inherit (inputs.nixpkgs.lib) nixosSystem;
inherit (inputs.home-manager.lib) homeManagerConfiguration;
};
serve-docs = pkgs.callPackage ../doc/server.nix {
inherit (config.packages) docs;
inherit (config.packages) doc;
};
palette-generator = pkgs.callPackage ../palette-generator { };
}
Expand Down