Convert to flake-parts & easy-hosts. Users broke
convert to using flake-parts and easy-hosts for the flake system. This allows me to remove my poor file-system based code and replace it with the code done in easy-hosts. Which also has good knock-on effects. This change factors users out of hosts, which is probably a good change since users aren't a nixos-module, but aren't completely untangled either. I'm going to leave users broken for a minute as I decide exactly how I want to handle them.
This commit is contained in:
parent
b416affd1f
commit
823c6d0738
9 changed files with 68 additions and 82 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -0,0 +1 @@
|
||||||
|
result
|
||||||
149
flake.nix
149
flake.nix
|
|
@ -1,94 +1,79 @@
|
||||||
{
|
{
|
||||||
inputs = {
|
outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
nixpkgs.url = "nixpkgs/nixos-unstable";
|
imports = with inputs; [
|
||||||
|
easy-hosts.flakeModule
|
||||||
|
# home-manager.flakeModules.home-manager
|
||||||
|
];
|
||||||
|
|
||||||
home-manager.url = "github:nix-community/home-manager";
|
systems = [ "x86-64-linux" ];
|
||||||
|
easy-hosts = {
|
||||||
|
autoConstruct = true;
|
||||||
|
path = ./hosts;
|
||||||
|
easy-hosts.onlySystem = "x86-64-linux";
|
||||||
|
|
||||||
lix-module.url = "https://git.lix.systems/lix-project/nixos-module/archive/2.91.1-2.tar.gz";
|
shared = {
|
||||||
|
modules = [
|
||||||
|
inputs.lix-module.nixosModules.default
|
||||||
|
./nixModules
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
hyprland.url = "git+https://github.com/hyprwm/Hyprland";
|
# flake = {
|
||||||
hyprland-contrib.url = "github:hyprwm/contrib";
|
# homeConfigurations = {};
|
||||||
|
# homeModules = { my-modules = ./hmModules; };
|
||||||
niri.url = "github:sodiboo/niri-flake";
|
# };
|
||||||
|
|
||||||
sops-nix.url = "github:Mic92/sops-nix";
|
|
||||||
ags.url = "github:Aylur/ags";
|
|
||||||
aagl.url = "github:ezKEa/aagl-gtk-on-nix";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, home-manager, nixpkgs, lix-module, ... }@inputs: let
|
inputs = {
|
||||||
system = "x86_64-linux";
|
# Save data with this url. Source:
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
# at://did:plc:mojgntlezho4qt7uvcfkdndg/app.bsky.feed.post/3loogwsoqok2w
|
||||||
fs = pkgs.lib.fileset;
|
# cid: bafyreidhuuxs3cuabneygtxir65hnd7hvy4hwj5rwrylpwmp7jhxciasve
|
||||||
st = pkgs.lib.strings;
|
nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz";
|
||||||
as = pkgs.lib.attrsets;
|
|
||||||
|
|
||||||
hosts = let
|
home-manager = {
|
||||||
hostFilter = { name, ...}: name == "host.nix";
|
type = "github";
|
||||||
hostPaths = fs.toList (fs.fileFilter hostFilter ./hosts);
|
owner = "nix-community";
|
||||||
# Assumes dir structure is start_of_path/hosts/hostname/host.nix
|
repo = "home-manager";
|
||||||
extractHostName = path: builtins.unsafeDiscardStringContext (
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
st.removeSuffix "/host.nix" (
|
|
||||||
builtins.elemAt (st.splitString "/hosts/" path) 1
|
|
||||||
)
|
|
||||||
);
|
|
||||||
in builtins.listToAttrs (map (path: {
|
|
||||||
value = path;
|
|
||||||
name = extractHostName path;
|
|
||||||
}) hostPaths);
|
|
||||||
|
|
||||||
users = let
|
|
||||||
userFilter = { name, ...}: name == "user.nix";
|
|
||||||
userPaths = fs.toList (fs.fileFilter userFilter ./hosts);
|
|
||||||
in builtins.listToAttrs (map (path: let
|
|
||||||
dirsAndFiles = st.splitString "/" path;
|
|
||||||
dAFLength = builtins.length dirsAndFiles;
|
|
||||||
# Assumes dir structure is start_of_path/hosts/hostname/users/username/user.nix
|
|
||||||
hostname = builtins.unsafeDiscardStringContext (
|
|
||||||
builtins.elemAt dirsAndFiles (dAFLength - 4));
|
|
||||||
username = builtins.unsafeDiscardStringContext (
|
|
||||||
builtins.elemAt dirsAndFiles (dAFLength - 2));
|
|
||||||
in {
|
|
||||||
name = username + "@" + hostname;
|
|
||||||
value = path;
|
|
||||||
}
|
|
||||||
) userPaths);
|
|
||||||
|
|
||||||
userConfig = usernameAtHostname: userpath: home-manager.lib.homeManagerConfiguration {
|
|
||||||
inherit pkgs;
|
|
||||||
extraSpecialArgs = {
|
|
||||||
inherit inputs;
|
|
||||||
inherit usernameAtHostname;
|
|
||||||
};
|
|
||||||
modules = [
|
|
||||||
./hmModules
|
|
||||||
userpath
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
hostConfig = hostname: hostpath: nixpkgs.lib.nixosSystem {
|
flake-parts = {
|
||||||
specialArgs = let
|
type = "github";
|
||||||
hostFilteredUsers = as.filterAttrs (
|
owner = "hercules-ci";
|
||||||
name: value: let
|
repo = "flake-parts";
|
||||||
userHostname = builtins.elemAt (st.splitString "@" name) 1;
|
inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||||
in userHostname == hostname
|
};
|
||||||
) users;
|
|
||||||
|
easy-hosts = {
|
||||||
hostUsers = as.mapAttrsToList (
|
type = "github";
|
||||||
name: value: builtins.elemAt (st.splitString "@" name) 0
|
owner = "tgirlcloud";
|
||||||
) hostFilteredUsers;
|
repo = "easy-hosts";
|
||||||
in {
|
};
|
||||||
inherit inputs;
|
|
||||||
inherit hostname;
|
lix = {
|
||||||
"usernameList" = hostUsers;
|
url = "https://git.lix.systems/lix-project/lix/archive/main.tar.gz";
|
||||||
};
|
flake = false;
|
||||||
modules = [
|
};
|
||||||
./nixosModules
|
|
||||||
hostpath
|
lix-module = {
|
||||||
];
|
url = "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
inputs.lix.follows = "lix";
|
||||||
|
};
|
||||||
|
|
||||||
|
niri = {
|
||||||
|
type = "github";
|
||||||
|
owner = "sodiboo";
|
||||||
|
repo = "niri-flake";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
|
sops-nix = {
|
||||||
|
type = "github";
|
||||||
|
owner = "Mic92";
|
||||||
|
repo = "sops-nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
in {
|
|
||||||
nixosConfigurations = builtins.mapAttrs (name: path: hostConfig name path) hosts;
|
|
||||||
homeConfigurations = builtins.mapAttrs (name: path: userConfig name path) users;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue