Skip to content
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

feat(modules): support nixos & home-manager's stable branches #182

Merged
merged 4 commits into from
May 21, 2024
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
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
name: Test Modules
runs-on: ubuntu-latest

strategy:
matrix:
test: [unstable, stable]

steps:
- uses: actions/checkout@v4

Expand All @@ -46,5 +50,10 @@ jobs:
uses: DeterminateSystems/magic-nix-cache-action@v6

- name: Run VM
env:
TEST: ${{ matrix.test }}
run: |
nix build --print-build-logs --show-trace ./dev#checks.x86_64-linux.module-vm-test
nix build \
--print-build-logs \
--show-trace \
"./dev#checks.x86_64-linux.module-test-$TEST"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ For [standalone installations](https://nix-community.github.io/home-manager/inde
A: You can find programs supported through home-manager [here](https://github.com/catppuccin/nix/tree/main/modules/home-manager),
and NixOS modules [here](https://github.com/catppuccin/nix/tree/main/modules/nixos)

- Q: **"What versions of NixOS and home-manager are supported?"**\
A: We primarily support the `unstable` branch, but try our best to support the current stable release.
You can check if your stable release is currently supported at [status.nixos.org](https://status.nixos.org/)

## 💝 Thanks to

- [Stonks3141](https://github.com/Stonks3141)
Expand Down
40 changes: 39 additions & 1 deletion dev/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions dev/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@

inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
nixpkgs-stable.url = "nixpkgs/release-23.11";

home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};

home-manager-stable = {
url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixpkgs-stable";
};
};

outputs = { self, nixpkgs, home-manager }:
outputs = { self, nixpkgs, nixpkgs-stable, home-manager, home-manager-stable }:
let
systems = [
"x86_64-linux"
Expand All @@ -19,7 +25,12 @@
"aarch64-darwin"
];

forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system});
nixpkgsFor = nixpkgs.lib.genAttrs systems (system: {
unstable = nixpkgs.legacyPackages.${system};
stable = nixpkgs-stable.legacyPackages.${system};
});

forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgsFor.${system}.unstable);
in
{
apps = forAllSystems ({ lib, pkgs, ... }: {
Expand All @@ -40,8 +51,11 @@
};
});

checks = forAllSystems ({ lib, pkgs, ... }: lib.optionalAttrs pkgs.stdenv.isLinux {
module-vm-test = pkgs.callPackage ../test.nix { inherit home-manager; };
checks = forAllSystems ({ lib, pkgs, system, ... }: lib.optionalAttrs pkgs.stdenv.isLinux {
module-test-unstable = pkgs.callPackage ../test.nix { inherit home-manager; };
module-test-stable = nixpkgsFor.${system}.stable.callPackage ../test.nix {
home-manager = home-manager-stable;
};
});

formatter = forAllSystems (pkgs: pkgs.nixpkgs-fmt);
Expand Down
9 changes: 7 additions & 2 deletions modules/home-manager/tofi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ let
inherit (config.catppuccin) sources;
cfg = config.programs.tofi.catppuccin;
enable = cfg.enable && config.programs.tofi.enable;

# `programs.tofi` was added in 24.05 and not backported
# TODO: remove when 24.05 is stable
minVersion = "24.05";
in
{
options.programs.tofi.catppuccin =
lib.ctp.mkCatppuccinOpt "tofi";
options.programs.tofi = lib.ctp.mkVersionedOpts minVersion {
catppuccin = lib.ctp.mkCatppuccinOpt "tofi";
};

config.programs.tofi = lib.mkIf enable {
settings = lib.ctp.fromINI (sources.tofi + /catppuccin-${cfg.flavour});
Expand Down
11 changes: 11 additions & 0 deletions modules/lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,15 @@ in
# by default enums cannot be merged, but they keep their passed value in `functor.payload`.
# `functor.binOp` can merge those values
mergeEnums = a: b: lib.types.enum (a.functor.binOp a.functor.payload b.functor.payload);

# string
# returns the current release version of nixos or home-manager. throws an evaluation error if neither are
# found
getModuleRelease = config.home.version.release or config.system.nixos.release or (throw "Couldn't determine release version!");

This comment was marked as resolved.


# string -> a -> a
# if the current module release is less than `minVersion`, all options are made no-ops with
# `lib.mkSinkUndeclaredOptions`
mkVersionedOpts = minVersion: option:
if lib.versionAtLeast ctp.getModuleRelease minVersion then option else lib.mkSinkUndeclaredOptions { };
}
70 changes: 38 additions & 32 deletions modules/nixos/sddm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,54 @@
, ...
}:
let
inherit (lib) mkIf ctp types mkOption versionAtLeast;
cfg = config.services.displayManager.sddm.catppuccin;
enable = cfg.enable && config.services.displayManager.sddm.enable;

inherit (lib) mkIf ctp types mkOption;
# versions >= 24.05 renamed `services.xserver.displayManager` to `services.displayManager`
# TODO: remove when 24.05 is stable
minVersion = "24.05";
in
{
options.services.displayManager.sddm.catppuccin =
ctp.mkCatppuccinOpt "sddm"
// {
font = mkOption {
type = types.str;
default = "Noto Sans";
description = "Font to use for the login screen";
};
options.services.displayManager = ctp.mkVersionedOpts minVersion {
sddm.catppuccin =
ctp.mkCatppuccinOpt "sddm"
// {
font = mkOption {
type = types.str;
default = "Noto Sans";
description = "Font to use for the login screen";
};

fontSize = mkOption {
type = types.str;
default = "9";
description = "Font size to use for the login screen";
};
fontSize = mkOption {
type = types.str;
default = "9";
description = "Font size to use for the login screen";
};

background = mkOption {
type = with types; (either path str);
default = "";
description = "Background image to use for the login screen";
};
background = mkOption {
type = with types; (either path str);
default = "";
description = "Background image to use for the login screen";
};

loginBackground = mkOption {
type = types.bool;
default = true;
description = "Add an additonal background layer to the login panel";
loginBackground = mkOption {
type = types.bool;
default = true;
description = "Add an additional background layer to the login panel";
};
};
};
};

config = mkIf enable {
config = mkIf enable
{
environment.systemPackages = [
(pkgs.catppuccin-sddm.override {
flavor = cfg.flavour;
inherit (cfg) font fontSize background loginBackground;
})
];
} // mkIf (enable && versionAtLeast ctp.getModuleRelease minVersion) {
services.displayManager.sddm.theme = "catppuccin-${cfg.flavour}";

environment.systemPackages = [
(pkgs.catppuccin-sddm.override {
flavor = cfg.flavour;
inherit (cfg) font fontSize background loginBackground;
})
];
};
}