Skip to content

Commit

Permalink
Refactor edge and homemade with overlays
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Nov 19, 2024
1 parent 97970d4 commit 02280df
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 181 deletions.
255 changes: 113 additions & 142 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
description = "kachick's dotfiles that can be placed in the public repository";

inputs = {
# Candidate channels
# - https://github.com/kachick/anylang-template/issues/17
Expand Down Expand Up @@ -59,6 +61,14 @@
mkNixpkgs =
system: if (nixpkgs.lib.strings.hasSuffix "-darwin" system) then nixpkgs-darwin else nixpkgs;

overlays = import ./overlays { inherit edge-nixpkgs; };

mkPkgs =
system:
import (mkNixpkgs system) {
inherit system overlays;
};

mkHomeManager =
system:
if (nixpkgs.lib.strings.hasSuffix "-darwin" system) then
Expand All @@ -72,34 +82,26 @@
type = "app";
program = (mkNixpkgs system).lib.getExe pkg;
};

homemade-packages = forAllSystems (
system:
((mkNixpkgs system).legacyPackages.${system}.callPackage ./pkgs {
edge-pkgs = edge-nixpkgs.legacyPackages.${system};
})
);
in
{
# nixfmt will be official
# - https://github.com/NixOS/nixfmt/issues/153
# - https://github.com/NixOS/nixfmt/issues/129
# - https://github.com/NixOS/rfcs/pull/166
# - https://github.com/NixOS/nixfmt/blob/a81f922a2b362f347a6cbecff5fb14f3052bc25d/README.md#L19
formatter = forAllSystems (system: (mkNixpkgs system).legacyPackages.${system}.nixfmt-rfc-style);
formatter = forAllSystems (system: (mkPkgs system).nixfmt-rfc-style);

devShells = forAllSystems (
system:
let
pkgs = (mkNixpkgs system).legacyPackages.${system};
homemade-pkgs = homemade-packages.${system};
pkgs = mkPkgs system;
in
{
default = pkgs.mkShellNoCC {
# Realize nixd pkgs version inlay hints for stable channel instead of latest
NIX_PATH = "nixpkgs=${pkgs.path}";

TYPOS_LSP_PATH = pkgs.lib.getExe pkgs.typos-lsp; # For vscode typos extension
TYPOS_LSP_PATH = pkgs.lib.getExe pkgs.unstable.typos-lsp; # For vscode typos extension

buildInputs =
(with pkgs; [
Expand Down Expand Up @@ -134,21 +136,27 @@

(ruby_3_3.withPackages (ps: with ps; [ rubocop ]))
])
++ (with homemade-pkgs; [ nix-hash-url ])
++ (with pkgs.my; [ nix-hash-url ])
++ [ inputs.selfup.packages.${system}.default ]
));
};
}
);

packages = forAllSystems (system: {
cozette = homemade-packages.${system}.cozette;
micro-kdl = homemade-packages.${system}.micro-kdl;
micro-nordcolors = homemade-packages.${system}.micro-nordcolors;
micro-everforest = homemade-packages.${system}.micro-everforest;
micro-catppuccin = homemade-packages.${system}.micro-catppuccin;
envs = homemade-packages.${system}.envs;
});
packages = forAllSystems (
system:
let
pkgs = mkPkgs system;
in
{
cozette = pkgs.my.cozette;
micro-kdl = pkgs.my.micro-kdl;
micro-nordcolors = pkgs.my.micro-nordcolors;
micro-everforest = pkgs.my.micro-everforest;
micro-catppuccin = pkgs.my.micro-catppuccin;
envs = pkgs.my.envs;
}
);

apps = forAllSystems (
system:
Expand All @@ -158,7 +166,7 @@
inherit name;
value = mkApp {
system = system;
pkg = homemade-packages.${system}.${name};
pkgs = (mkPkgs system).my.${name};
};
})
[
Expand Down Expand Up @@ -203,21 +211,13 @@
nixosConfigurations =
let
system = "x86_64-linux";
edge-pkgs = import edge-nixpkgs {
inherit system;
config = {
allowUnfree = true;
};
};
homemade-pkgs = homemade-packages.${system};
shared = {
inherit system;
specialArgs = {
inherit
inputs
outputs
homemade-pkgs
edge-pkgs
overlays
;
};
};
Expand All @@ -230,127 +230,98 @@

homeConfigurations =
let
x86-Linux = {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
extraSpecialArgs = {
homemade-pkgs = homemade-packages.x86_64-linux;
edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-linux;
};
};

x86-macOS = {
pkgs = nixpkgs-darwin.legacyPackages.x86_64-darwin;
extraSpecialArgs = {
homemade-pkgs = homemade-packages.x86_64-darwin;
edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-darwin;
};
};
x86-Linux-pkgs = mkPkgs "x86_64-linux";
x86-macOS-pkgs = mkPkgs "x86_64-darwin";
in
{
"kachick@nixos-desktop" = home-manager-linux.lib.homeManagerConfiguration (
x86-Linux
// {
modules = [
./home-manager/kachick.nix
./home-manager/linux.nix
{ targets.genericLinux.enable = false; }
./home-manager/lima-host.nix
./home-manager/systemd.nix
./home-manager/gnome.nix
./home-manager/firefox.nix
];
}
);
"kachick@nixos-desktop" = home-manager-linux.lib.homeManagerConfiguration ({
pkgs = x86-Linux-pkgs;
modules = [
./home-manager/kachick.nix
./home-manager/linux.nix
{ targets.genericLinux.enable = false; }
./home-manager/lima-host.nix
./home-manager/systemd.nix
./home-manager/gnome.nix
./home-manager/firefox.nix
];
});

"kachick@wsl-ubuntu" = home-manager-linux.lib.homeManagerConfiguration (
x86-Linux
// {
modules = [
./home-manager/kachick.nix
./home-manager/linux.nix
./home-manager/genericLinux.nix
./home-manager/wsl.nix
];
}
);
"kachick@wsl-ubuntu" = home-manager-linux.lib.homeManagerConfiguration ({
pkgs = x86-Linux-pkgs;
modules = [
./home-manager/kachick.nix
./home-manager/linux.nix
./home-manager/genericLinux.nix
./home-manager/wsl.nix
];
});

"nixos@wsl-nixos" = home-manager-linux.lib.homeManagerConfiguration (
x86-Linux
// {
modules = [
./home-manager/kachick.nix
./home-manager/linux.nix
{
home.username = "nixos";
targets.genericLinux.enable = false;
}
./home-manager/wsl.nix
];
}
);
"nixos@wsl-nixos" = home-manager-linux.lib.homeManagerConfiguration ({
pkgs = x86-Linux-pkgs;
modules = [
./home-manager/kachick.nix
./home-manager/linux.nix
{
home.username = "nixos";
targets.genericLinux.enable = false;
}
./home-manager/wsl.nix
];
});

"kachick@macbook" = home-manager-darwin.lib.homeManagerConfiguration (
x86-macOS
// {
modules = [
./home-manager/kachick.nix
./home-manager/darwin.nix
];
}
);
"kachick@macbook" = home-manager-darwin.lib.homeManagerConfiguration ({
pkgs = x86-macOS-pkgs;
modules = [
./home-manager/kachick.nix
./home-manager/darwin.nix
];
});

"kachick@lima" = home-manager-darwin.lib.homeManagerConfiguration (
x86-Linux
// {
modules = [
./home-manager/kachick.nix
./home-manager/linux.nix
./home-manager/genericLinux.nix
./home-manager/lima-guest.nix
];
}
);
"kachick@lima" = home-manager-darwin.lib.homeManagerConfiguration ({
pkgs = x86-Linux-pkgs;
modules = [
./home-manager/kachick.nix
./home-manager/linux.nix
./home-manager/genericLinux.nix
./home-manager/lima-guest.nix
];
});

"[email protected]" = home-manager-linux.lib.homeManagerConfiguration (
x86-Linux
// {
# Prefer "kachick" over "common" only here.
# Using values as much as possible as actual values to create a robust CI
modules = [
./home-manager/kachick.nix
./home-manager/linux.nix
{ home.username = "runner"; }
./home-manager/genericLinux.nix
./home-manager/systemd.nix
];
}
);
"[email protected]" = home-manager-linux.lib.homeManagerConfiguration ({
pkgs = x86-Linux-pkgs;
# Prefer "kachick" over "common" only here.
# Using values as much as possible as actual values to create a robust CI
modules = [
./home-manager/kachick.nix
./home-manager/linux.nix
{ home.username = "runner"; }
./home-manager/genericLinux.nix
./home-manager/systemd.nix
];
});

"github-actions@macos-13" = home-manager-darwin.lib.homeManagerConfiguration (
x86-macOS
// {
# Prefer "kachick" over "common" only here.
# Using values as much as possible as actual values to create a robust CI
modules = [
./home-manager/kachick.nix
./home-manager/darwin.nix
{ home.username = "runner"; }
];
}
);
"github-actions@macos-13" = home-manager-darwin.lib.homeManagerConfiguration ({
pkgs = x86-macOS-pkgs;
# Prefer "kachick" over "common" only here.
# Using values as much as possible as actual values to create a robust CI
modules = [
./home-manager/kachick.nix
./home-manager/darwin.nix
{ home.username = "runner"; }
];
});

"user@linux-cli" = home-manager-linux.lib.homeManagerConfiguration (
x86-Linux
// {
modules = [
./home-manager/common.nix
{ home.username = "user"; }
./home-manager/linux.nix
./home-manager/genericLinux.nix
./home-manager/systemd.nix
];
}
);
"user@linux-cli" = home-manager-linux.lib.homeManagerConfiguration ({
pkgs = x86-Linux-pkgs;
modules = [
./home-manager/common.nix
{ home.username = "user"; }
./home-manager/linux.nix
./home-manager/genericLinux.nix
./home-manager/systemd.nix
];
});
};
};
}
3 changes: 1 addition & 2 deletions home-manager/bash.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
config,
lib,
pkgs,
homemade-pkgs,
...
}:

Expand Down Expand Up @@ -133,7 +132,7 @@
# Disable `Ctrl + S(no output tty)`
${lib.getBin pkgs.coreutils}/bin/stty stop undef
source "${homemade-pkgs.posix_shared_functions}"
source "${pkgs.my.posix_shared_functions}"
if [ 'linux' = "$TERM" ]; then
# Avoid Tofu
Expand Down
4 changes: 0 additions & 4 deletions home-manager/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
config,
pkgs,
lib,
edge-pkgs,
homemade-pkgs,
...
}:

Expand Down Expand Up @@ -68,8 +66,6 @@

packages = import ./packages.nix {
inherit pkgs;
inherit edge-pkgs;
inherit homemade-pkgs;
};

# You can check the candidates in `locale -a`
Expand Down
3 changes: 1 addition & 2 deletions home-manager/darwin.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
pkgs,
# Don't depend on edge-pkgs as possible until realize https://github.com/NixOS/nixpkgs/issues/107466,
pkgs, # Don't depend on edge-pkgs as possible until realize https://github.com/NixOS/nixpkgs/issues/107466,
config,
...
}:
Expand Down
Loading

0 comments on commit 02280df

Please sign in to comment.