dot

NixOS dotfiles
git clone https://git.echoz.io/dot.git
Log | Files | Refs

flake.nix (3603B)


      1 {
      2   inputs = {
      3     nixpkgs.url = "nixpkgs/nixos-unstable";
      4 
      5     disko.url = "github:nix-community/disko/v1.12.0";
      6     home-manager.url = "github:nix-community/home-manager";
      7     impermanence.url = "github:nix-community/impermanence";
      8     sops-nix.url = "github:Mic92/sops-nix";
      9     walker.url = "github:abenz1267/walker";
     10     elephant.url = "github:abenz1267/elephant";
     11     nixpak.url = "github:nixpak/nixpak";
     12     nix-flatpak.url = "github:gmodena/nix-flatpak/v0.6.0";
     13     imsh-clients.url = "github:echozio/imsh-clients";
     14 
     15     disko.inputs.nixpkgs.follows = "nixpkgs";
     16     home-manager.inputs.nixpkgs.follows = "nixpkgs";
     17     sops-nix.inputs.nixpkgs.follows = "nixpkgs";
     18     walker.inputs.nixpkgs.follows = "nixpkgs";
     19     walker.inputs.elephant.follows = "elephant";
     20     elephant.inputs.nixpkgs.follows = "nixpkgs";
     21     nixpak.inputs.nixpkgs.follows = "nixpkgs";
     22     imsh-clients.inputs.nixpkgs.follows = "nixpkgs";
     23 
     24     sec.url = "github:echozio/sec";
     25   };
     26 
     27   outputs =
     28     inputs@{
     29       self,
     30       disko,
     31       nixpkgs,
     32       ...
     33     }:
     34     let
     35       lib = nixpkgs.lib;
     36       systems = [
     37         "x86_64-linux"
     38         "aarch64-linux"
     39       ];
     40       argsFor = system: {
     41         pkgs = nixpkgs.legacyPackages.${system};
     42         disko = disko.packages.${system}.disko;
     43       };
     44       forAllSystems = f: lib.genAttrs systems (system: f (argsFor system));
     45     in
     46     {
     47       devShells = forAllSystems (
     48         { pkgs, disko, ... }:
     49         {
     50           default = pkgs.mkShell {
     51             packages = with pkgs; [
     52               nixos-rebuild
     53               nixos-anywhere
     54               ssh-to-age
     55               disko
     56               (writeShellScriptBin "generate-host-keys" ''
     57                 host="$1"
     58                 out="tmp/fix"
     59                 if [ -z "$host" ]; then
     60                   echo "Usage: $(basename "$0") hostname" >&2
     61                   exit 1
     62                 fi
     63                 umask 0022
     64                 mkdir -p "$out/etc/ssh"
     65                 ${openssh}/bin/ssh-keygen -t ed25519 -f "$out/etc/ssh/ssh_host_ed25519_key" -C "root@$host" -q -N ""
     66                 cat <<EOF
     67                 age public key:
     68                   $(${ssh-to-age}/bin/ssh-to-age < "$out/etc/ssh/ssh_host_ed25519_key.pub")
     69 
     70                 install with:
     71                   nixos-anywhere --flake .#$host --extra-files tmp --target-host root@$host
     72 
     73                 remember to:
     74                   rm -rf tmp
     75                 EOF
     76 
     77               '')
     78             ];
     79           };
     80         }
     81       );
     82       packages = forAllSystems (
     83         { pkgs, ... }:
     84         {
     85           neovim-minimal = pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped {
     86             vimAlias = true;
     87             viAlias = true;
     88             luaRcContent = builtins.readFile ./neovim.lua;
     89             withRuby = false;
     90           };
     91         }
     92       );
     93 
     94       nixosModules.default = ./modules;
     95 
     96       nixosConfigurations =
     97         let
     98           mkHost =
     99             module:
    100             lib.nixosSystem {
    101               specialArgs = inputs;
    102               modules = [
    103                 self.nixosModules.default
    104                 module
    105               ];
    106             };
    107         in
    108         {
    109           vm = mkHost ./hosts/vm;
    110           rc = mkHost ./hosts/rc;
    111           ws = mkHost ./hosts/ws;
    112           tp = mkHost ./hosts/tp;
    113         };
    114 
    115       formatter = forAllSystems (
    116         { pkgs, ... }:
    117         pkgs.treefmt.withConfig {
    118           settings = {
    119             on-unmatched = "info";
    120             formatter.nixfmt = {
    121               command = lib.getExe pkgs.nixfmt;
    122               includes = [ "*.nix" ];
    123             };
    124           };
    125         }
    126       );
    127     };
    128 }