elvos

30 commits
Updated 2026-06-12 16:26:02
.
./flake.nix
{
  description = "ELV Flake";

  inputs = {
    nixpkgs.url = "nixpkgs/nixos-26.05";

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

    rust-overlay = {
      url = "github:oxalica/rust-overlay/stable";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs =
    {
      nixpkgs,
      home-manager,
      rust-overlay,
      ...
    }@inputs:
    let
      nlib = nixpkgs.lib;
      hlib = home-manager.lib;

      overlays = [
        rust-overlay.overlays.default
        (final: prev: {
          rust-toolchain = prev.rust-bin.stable.latest.default.override {
            extensions = [
              "rust-src"
              "rust-analyzer"
            ];
            targets = [
              "x86_64-unknown-linux-gnu"
              "x86_64-unknown-linux-musl"
            ];
          };
        })
      ];

      pkgs = import nixpkgs {
        system = "x86_64-linux";
        config.allowUnfree = true;
        inherit overlays;
      };

      hosts = builtins.filter (x: x != null) (
        nlib.mapAttrsToList (
          name: value:
          if (value == "regular" && nlib.hasSuffix ".nix" name) then nlib.removeSuffix ".nix" name else null
        ) (builtins.readDir ./hosts)
      );

      homes = builtins.filter (x: x != null) (
        nlib.mapAttrsToList (
          name: value:
          if (value == "regular" && nlib.hasSuffix ".nix" name) then nlib.removeSuffix ".nix" name else null
        ) (builtins.readDir ./homes)
      );
    in
    {
      nixosConfigurations = builtins.listToAttrs (
        map (host: {
          name = host;
          value = nlib.nixosSystem {
            system = "x86_64-linux";
            pkgs = pkgs;
            modules = [
              { networking.hostName = host; }
              (./hosts + "/${host}.nix")
            ];
          };
        }) hosts
      );
      homeConfigurations = builtins.listToAttrs (
        map (home: {
          name = home;
          value = hlib.homeManagerConfiguration {
            pkgs = pkgs;
            modules = [
              { home.stateVersion = "26.05"; }
              (./homes + "/${home}.nix")
            ];
            extraSpecialArgs = {
              inherit inputs;
            };
          };
        }) homes
      );
    };
}