refactor: flake.nix looks nicer

This commit is contained in:
Mohammad Rafiq 2025-03-26 20:40:46 +08:00
parent 65655e8391
commit 71a947e285
No known key found for this signature in database
3 changed files with 50 additions and 227 deletions

View file

@ -1,73 +1,56 @@
{
description = "flake forward setup with two hosts on different architectures";
outputs =
{
self,
nixpkgs,
home-manager,
...
}@inputs:
let
forEachSupportedSystem =
f:
nixpkgs.lib.genAttrs
[
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
(
system:
f {
pkgs = import nixpkgs { inherit system; };
}
);
args = { inherit self inputs; };
mkSystem =
hostname:
nixpkgs.lib.nixosSystem {
specialArgs = args;
modules = [
./systems/${hostname}.nix
home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = args;
users.rafiq.imports = [
./users/rafiq.nix
];
};
}
];
};
mkListItem = hostname: {
mkSystem = type: hostname: {
name = "${hostname}";
value = mkSystem "${hostname}";
value =
let
args = { inherit self inputs type; };
in
inputs.nixpkgs.lib.nixosSystem {
specialArgs = args;
modules = [
./systems/${hostname}.nix
inputs.home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = args;
users.rafiq.imports = [
./users/rafiq.nix
];
};
}
];
};
};
in
{
# System Configurations
nixosConfigurations = builtins.listToAttrs [
(mkListItem "nemesis")
(mkListItem "mellinoe")
(mkSystem "desktop" "nemesis")
(mkSystem "desktop" "mellinoe")
];
};
inputs = {
hyprland-plugins.inputs.hyprland.follows = "hyprland";
hyprland-plugins.url = "github:hyprwm/hyprland-plugins";
wii-cursor.path = "/home/rafiq/repos/dotfiles/media/wii-cursors-xcursor";
wii-cursor.type = "path";
ags.inputs.nixpkgs.follows = "nixpkgs";
ags.url = "github:aylur/ags";
astal.inputs.nixpkgs.follows = "nixpkgs";
astal.url = "github:aylur/astal";
disko.inputs.nixpkgs.follows = "nixpkgs";
disko.url = "github:nix-community/disko/latest";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager";
hyprcloser.url = "github:rrvsh/hyprcloser";
hyprland-plugins.inputs.hyprland.follows = "hyprland";
hyprland-plugins.url = "github:hyprwm/hyprland-plugins";
hyprland.url = "github:hyprwm/Hyprland";
hyprlock.url = "github:hyprwm/hyprlock";
hyprshaders.flake = false;
@ -78,16 +61,10 @@
nixd.url = "github:nix-community/nixd";
nixos-hardware.url = "github:nixos/nixos-hardware";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixvim.inputs.nixpkgs.follows = "nixpkgs";
nixvim.url = "github:nix-community/nixvim";
nvf.url = "github:notashelf/nvf";
sops-nix.url = "github:Mic92/sops-nix";
spicetify-nix.url = "github:Gerg-L/spicetify-nix";
stylix.url = "github:danth/stylix";
yazi.url = "github:sxyazi/yazi";
astal.url = "github:aylur/astal";
astal.inputs.nixpkgs.follows = "nixpkgs";
ags.url = "github:aylur/ags";
ags.inputs.nixpkgs.follows = "nixpkgs";
};
}