From 823c6d0738a7961b63c9a22f813284f5880a0de3 Mon Sep 17 00:00:00 2001 From: Julia Lange Date: Mon, 17 Nov 2025 09:05:48 -0800 Subject: [PATCH] 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. --- .gitignore | 1 + flake.nix | 149 ++++++++---------- hosts/jibril/{host.nix => default.nix} | 0 hosts/juri/{host.nix => default.nix} | 0 hosts/onizuka/{host.nix => default.nix} | 0 .../users/badtz => users/badtz@juri}/user.nix | 0 .../users/pan => users/pan@jibril}/user.nix | 0 .../users/pan => users/pan@juri}/user.nix | 0 .../users/pan => users/pan@onizuka}/user.nix | 0 9 files changed, 68 insertions(+), 82 deletions(-) rename hosts/jibril/{host.nix => default.nix} (100%) rename hosts/juri/{host.nix => default.nix} (100%) rename hosts/onizuka/{host.nix => default.nix} (100%) rename {hosts/juri/users/badtz => users/badtz@juri}/user.nix (100%) rename {hosts/jibril/users/pan => users/pan@jibril}/user.nix (100%) rename {hosts/juri/users/pan => users/pan@juri}/user.nix (100%) rename {hosts/onizuka/users/pan => users/pan@onizuka}/user.nix (100%) diff --git a/.gitignore b/.gitignore index e69de29..b2be92b 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/flake.nix b/flake.nix index eeb4bd0..568e458 100644 --- a/flake.nix +++ b/flake.nix @@ -1,94 +1,79 @@ { - inputs = { - nixpkgs.url = "nixpkgs/nixos-unstable"; + outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } { + 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"; - hyprland-contrib.url = "github:hyprwm/contrib"; - - 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"; + # flake = { + # homeConfigurations = {}; + # homeModules = { my-modules = ./hmModules; }; + # }; }; - outputs = { self, home-manager, nixpkgs, lix-module, ... }@inputs: let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - fs = pkgs.lib.fileset; - st = pkgs.lib.strings; - as = pkgs.lib.attrsets; + inputs = { + # Save data with this url. Source: + # at://did:plc:mojgntlezho4qt7uvcfkdndg/app.bsky.feed.post/3loogwsoqok2w + # cid: bafyreidhuuxs3cuabneygtxir65hnd7hvy4hwj5rwrylpwmp7jhxciasve + nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"; - hosts = let - hostFilter = { name, ...}: name == "host.nix"; - hostPaths = fs.toList (fs.fileFilter hostFilter ./hosts); - # Assumes dir structure is start_of_path/hosts/hostname/host.nix - extractHostName = path: builtins.unsafeDiscardStringContext ( - 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 - ]; + home-manager = { + type = "github"; + owner = "nix-community"; + repo = "home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; }; - hostConfig = hostname: hostpath: nixpkgs.lib.nixosSystem { - specialArgs = let - hostFilteredUsers = as.filterAttrs ( - name: value: let - userHostname = builtins.elemAt (st.splitString "@" name) 1; - in userHostname == hostname - ) users; - - hostUsers = as.mapAttrsToList ( - name: value: builtins.elemAt (st.splitString "@" name) 0 - ) hostFilteredUsers; - in { - inherit inputs; - inherit hostname; - "usernameList" = hostUsers; - }; - modules = [ - ./nixosModules - hostpath - ]; + flake-parts = { + type = "github"; + owner = "hercules-ci"; + repo = "flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; + + easy-hosts = { + type = "github"; + owner = "tgirlcloud"; + repo = "easy-hosts"; + }; + + lix = { + url = "https://git.lix.systems/lix-project/lix/archive/main.tar.gz"; + flake = false; + }; + + 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; }; } diff --git a/hosts/jibril/host.nix b/hosts/jibril/default.nix similarity index 100% rename from hosts/jibril/host.nix rename to hosts/jibril/default.nix diff --git a/hosts/juri/host.nix b/hosts/juri/default.nix similarity index 100% rename from hosts/juri/host.nix rename to hosts/juri/default.nix diff --git a/hosts/onizuka/host.nix b/hosts/onizuka/default.nix similarity index 100% rename from hosts/onizuka/host.nix rename to hosts/onizuka/default.nix diff --git a/hosts/juri/users/badtz/user.nix b/users/badtz@juri/user.nix similarity index 100% rename from hosts/juri/users/badtz/user.nix rename to users/badtz@juri/user.nix diff --git a/hosts/jibril/users/pan/user.nix b/users/pan@jibril/user.nix similarity index 100% rename from hosts/jibril/users/pan/user.nix rename to users/pan@jibril/user.nix diff --git a/hosts/juri/users/pan/user.nix b/users/pan@juri/user.nix similarity index 100% rename from hosts/juri/users/pan/user.nix rename to users/pan@juri/user.nix diff --git a/hosts/onizuka/users/pan/user.nix b/users/pan@onizuka/user.nix similarity index 100% rename from hosts/onizuka/users/pan/user.nix rename to users/pan@onizuka/user.nix