{
  description = "nipsy's NixOS configurations";

  inputs = {

    disko = {
      url = "github:nix-community/disko";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    #ghostty = {
    #  url = "github:ghostty-org/ghostty";
    #};

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

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

    nixos-hardware.url = "github:nixos/nixos-hardware";

    # persistent base NixOS URLs
    nixpkgs-master.url = "github:NixOS/nixpkgs";
    nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-26.05";
    #nixpkgs-staging.url = "github:NixOS/nixpkgs/staging-nixos";
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

    # specific nixpkgs commit for EOL kernel and ZFS
    nixpkgs-kerneol.url ="github:NixOS/nixpkgs/ae05d822afa333fd35d417b399beb1da0ebb689d";

    # per https://nixos-and-flakes.thiscute.world/nixos-with-flakes/downgrade-or-upgrade-packages
    #my-nixpkgs.url = "github:nipsy/nixpkgs/update_reaper_7.61";
    #nixpkgs-67e692392.url = "github:nixos/nixpkgs/67e69239226f37168d1adb8d29bd61150756a03e";
    nixpkgs-pr540730.url = "github:rnhmjoj/nixpkgs/pr-fix-mkvtoolnix";
    #nixpkgs-wine9_22.url = "github:nixos/nixpkgs/dea5930f0ed8c29d3758d5ade9898b4e99d80b74";

    nvidia-patch = {
      url = "github:icewind1991/nvidia-patch-nixos";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    sops-nix = {
      url = "github:Mic92/sops-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };

  };

  outputs = {
    disko,
    #home-manager-stable,
    home-manager,
    #my-nixpkgs,
    nixos-hardware,
    nixpkgs-kerneol,
    nixpkgs-master,
    nixpkgs-pr540730,
    nixpkgs-stable,
    #nixpkgs-staging,
    #nixpkgs-wine9_22,
    nixpkgs,
    nvidia-patch,
    self,
    sops-nix,
    ...
  } @ inputs: let
    inherit (self) outputs;
    systems = [
      #"aarch64-linux"
      #"i686-linux"
      "x86_64-linux"
      #"aarch64-darwin"
      #"x86_64-darwin"
    ];
    forAllSystems = nixpkgs.lib.genAttrs systems;
  in {

    nixosConfigurations = {

      arrakis = nixpkgs.lib.nixosSystem {
        specialArgs = { inherit inputs outputs; };
        modules = [
          #{
          #  environment.systemPackages = [
          #    ghostty.packages.x86_64-linux.default
          #  ];
          #}
          disko.nixosModules.disko
          ./hosts/arrakis
          home-manager.nixosModules.home-manager {
            home-manager.sharedModules = [ sops-nix.homeManagerModules.sops ];
            home-manager.users.root = import ./home/root/arrakis.nix;
            home-manager.users.nipsy = import ./home/nipsy/arrakis.nix;
          }
          sops-nix.nixosModules.sops
        ];
      };

      caladan = nixpkgs.lib.nixosSystem {
        specialArgs = { inherit inputs outputs; };
        modules = [
          #({ config, pkgs, ... }:
          #  let
          #    overlay-nixos-rebuild-ng-pr495610 = final: prev: {
          #      nixos-rebuild-ng = nixpkgs-pr495610.legacyPackages."x86_64-linux".nixos-rebuild-ng;
          #    };
          #  in {
          #    nixpkgs.overlays = [ overlay-nixos-rebuild-ng-pr495610 ];
          #})
          #({ config, pkgs, ... }:
          #  let
          #    overlay-my-nixpkgs = final: prev: {
          #      reaper = my-nixpkgs.legacyPackages."x86_64-linux".reaper;
          #    };
          #  in {
          #    nixpkgs.overlays = [ overlay-my-nixpkgs ];
          #})
          disko.nixosModules.disko
          ./hosts/caladan
          home-manager.nixosModules.home-manager {
            home-manager.sharedModules = [ sops-nix.homeManagerModules.sops ];
            home-manager.users.root = import ./home/root/caladan.nix;
            home-manager.users.nipsy = import ./home/nipsy/caladan.nix;
          }
          sops-nix.nixosModules.sops
        ];
      };

      darkstar = nixpkgs.lib.nixosSystem {
        specialArgs = { inherit inputs outputs; };
        modules = [
          disko.nixosModules.disko
          ./hosts/darkstar
          home-manager.nixosModules.home-manager {
            #home-manager.sharedModules = [ sops-nix.homeManagerModules.sops ];
            home-manager.users.root = import ./home/root/darkstar.nix;
            home-manager.users.nipsy = import ./home/nipsy/darkstar.nix;
          }
          sops-nix.nixosModules.sops
        ];
      };

      fangorn = nixpkgs.lib.nixosSystem rec {
        specialArgs = { inherit inputs outputs; };
        modules = [
          disko.nixosModules.disko
          ./hosts/fangorn
          home-manager.nixosModules.home-manager {
            home-manager.sharedModules = [ sops-nix.homeManagerModules.sops ];
            home-manager.users.root = import ./home/root/fangorn.nix;
            home-manager.users.don = import ./home/don/fangorn.nix;
            home-manager.users.nipsy = import ./home/nipsy/fangorn.nix;
          }
          sops-nix.nixosModules.sops
        ];
      };

      ginaz = nixpkgs.lib.nixosSystem rec {
        specialArgs = { inherit inputs outputs; };
        modules = [
          disko.nixosModules.disko
          ./hosts/ginaz
          home-manager.nixosModules.home-manager {
            home-manager.sharedModules = [ sops-nix.homeManagerModules.sops ];
            home-manager.users.root = import ./home/root/ginaz.nix;
            home-manager.users.nipsy = import ./home/nipsy/ginaz.nix;
          }
          nixos-hardware.nixosModules.lenovo-yoga-7-14ARH7-amdgpu
          sops-nix.nixosModules.sops
        ];
      };

      # from https://nixos.wiki/wiki/Creating_a_NixOS_live_CD and https://chengeric.com/homelab/
      iso = nixpkgs.lib.nixosSystem {
        modules = [
          ({ modulesPath, pkgs, ... }: {
            environment.systemPackages = [
              pkgs.acl
              pkgs.bash
              pkgs.bc
              pkgs.bzip2
              pkgs.conntrack-tools
              pkgs.coreutils
              pkgs.cpio
              pkgs.csvkit
              pkgs.curl
              pkgs.debootstrap
              pkgs.diffutils
              pkgs.dig
              pkgs.dmidecode
              pkgs.elinks
              #pkgs.encfs
              pkgs.ethtool
              pkgs.exfatprogs
              pkgs.expect
              pkgs.file
              pkgs.findutils
              pkgs.fio
              pkgs.fping
              pkgs.git
              pkgs.gnugrep
              pkgs.gnupatch
              pkgs.gnused
              pkgs.gnutar
              pkgs.gptfdisk
              pkgs.gzip
              pkgs.htop
              pkgs.iotop
              pkgs.ipcalc
              pkgs.iperf
              pkgs.iproute2
              pkgs.iputils
              pkgs.jq
              pkgs.less
              pkgs.lshw
              pkgs.lsof
              pkgs.lvm2
              pkgs.moreutils
              pkgs.nano
              pkgs.netcat-openbsd
              pkgs.nettools
              pkgs.nmap
              pkgs.ntfs3g
              pkgs.openldap
              pkgs.openssl
              pkgs.p7zip
              pkgs.parted
              pkgs.pciutils
              pkgs.perf
              pkgs.perl5Packages.ArchiveZip
              pkgs.procps
              pkgs.progress
              pkgs.psmisc
              pkgs.pv
              pkgs.pwgen
              pkgs.recode
              pkgs.rsync
              pkgs.sg3_utils
              pkgs.smartmontools
              pkgs.socat
              pkgs.speedtest-cli
              pkgs.sqlite
              pkgs.sshfs
              pkgs.strace
              pkgs.sysstat
              pkgs.tcpdump
              pkgs.tmux
              pkgs.tftp-hpa
              pkgs.tlp
              pkgs.traceroute
              pkgs.tree
              pkgs.tshark
              pkgs.unixtools.xxd
              pkgs.unrar
              pkgs.unzip
              pkgs.usbutils
              pkgs.util-linux
              pkgs.vim
              pkgs.w3m
              pkgs.wdiff
              pkgs.wget
              pkgs.whois
              pkgs.wireguard-tools
              pkgs.xz
              pkgs.zip
            ];

            imports = [ (modulesPath + "/installer/cd-dvd/installation-cd-minimal.nix") ];

            #isoImage.squashfsCompression = "gzip -Xcompression-level 1";

            nix.settings.experimental-features = [ "nix-command" "flakes" ];

            nixpkgs.config.allowUnfree = true;

            services = {
              fwupd.enable = true;

              openssh = {
                enable = true;
                openFirewall = true;

                settings = {
                  PasswordAuthentication = false;
                  KbdInteractiveAuthentication = false;
                };
              };

              udisks2.enable = true;
            };

            users.users = {
              nixos.openssh.authorizedKeys.keys = [ (builtins.readFile ./hosts/common/users/nipsy/keys/id_arrakis.pub) ];
              root.openssh.authorizedKeys.keys = [ (builtins.readFile ./hosts/common/users/nipsy/keys/id_arrakis.pub) ];
            };
          })
          { nixpkgs.hostPlatform = "x86_64-linux"; }
        ];
      };

      kaitain = nixpkgs.lib.nixosSystem rec {
        specialArgs = { inherit inputs outputs; };
        modules = [
          disko.nixosModules.disko
          ./hosts/kaitain
          home-manager.nixosModules.home-manager {
            #home-manager.sharedModules = [ sops-nix.homeManagerModules.sops ];
            home-manager.users.root = import ./home/root/kaitain.nix;
            home-manager.users.nipsy = import ./home/nipsy/kaitain.nix;
          }
          sops-nix.nixosModules.sops
        ];
      };

      jupiter = nixpkgs.lib.nixosSystem rec {
        specialArgs = { inherit inputs outputs; };
        modules = [
          disko.nixosModules.disko
          ./hosts/jupiter
          home-manager.nixosModules.home-manager {
            #home-manager.sharedModules = [ sops-nix.homeManagerModules.sops ];
            home-manager.users.root = import ./home/root/jupiter.nix;
            home-manager.users.nipsy = import ./home/nipsy/jupiter.nix;
          }
          #sops-nix.nixosModules.sops
        ];
      };

      neptune = nixpkgs.lib.nixosSystem rec {
        specialArgs = { inherit inputs outputs; };
        modules = [
          disko.nixosModules.disko
          ./hosts/neptune
          home-manager.nixosModules.home-manager {
            #home-manager.sharedModules = [ sops-nix.homeManagerModules.sops ];
            home-manager.users.root = import ./home/root/neptune.nix;
            home-manager.users.nipsy = import ./home/nipsy/neptune.nix;
          }
          #sops-nix.nixosModules.sops
        ];
      };

      netboot = nixpkgs.lib.nixosSystem {
        modules = [
          "${nixpkgs}/nixos/modules/installer/netboot/netboot-minimal.nix"
          ({
            #isoImage.squashfsCompression = "gzip -Xcompression-level 1";
            nix.settings.experimental-features = [ "nix-command" "flakes" ];
            users.users = {
              nixos.openssh.authorizedKeys.keys = [ (builtins.readFile ./hosts/common/users/nipsy/keys/id_arrakis.pub) ];
              root.openssh.authorizedKeys.keys = [ (builtins.readFile ./hosts/common/users/nipsy/keys/id_arrakis.pub) ];
            };
          })
          { nixpkgs.hostPlatform = "x86_64-linux"; }
        ];
      };

      richese = nixpkgs.lib.nixosSystem rec {
        specialArgs = { inherit inputs outputs; };
        modules = [
          disko.nixosModules.disko
          ./hosts/richese
          home-manager.nixosModules.home-manager {
            #home-manager.sharedModules = [ sops-nix.homeManagerModules.sops ];
            home-manager.users.root = import ./home/root/richese.nix;
            home-manager.users.nipsy = import ./home/nipsy/richese.nix;
          }
          sops-nix.nixosModules.sops
        ];
      };

      saturn = nixpkgs.lib.nixosSystem rec {
        specialArgs = { inherit inputs outputs; };
        modules = [
          disko.nixosModules.disko
          ./hosts/saturn
          home-manager.nixosModules.home-manager {
            #home-manager.sharedModules = [ sops-nix.homeManagerModules.sops ];
            home-manager.users.root = import ./home/root/saturn.nix;
            home-manager.users.nipsy = import ./home/nipsy/saturn.nix;
          }
          #sops-nix.nixosModules.sops
        ];
      };

      uranus = nixpkgs.lib.nixosSystem rec {
        specialArgs = { inherit inputs outputs; };
        modules = [
          disko.nixosModules.disko
          ./hosts/uranus
          home-manager.nixosModules.home-manager {
            #home-manager.sharedModules = [ sops-nix.homeManagerModules.sops ];
            home-manager.users.root = import ./home/root/uranus.nix;
            home-manager.users.nipsy = import ./home/nipsy/uranus.nix;
          }
          #sops-nix.nixosModules.sops
        ];
      };

    };

    overlays = import ./overlays {inherit inputs;};
    packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system});

  };

}
