From db6503a855d746cbc1581f160f44010dd00cf243 Mon Sep 17 00:00:00 2001 From: Jake Hillion Date: Fri, 8 Sep 2023 20:51:42 +0100 Subject: [PATCH] tywin: storj: enable on d3 --- README.md | 8 +- flake.nix | 129 ++++++++++-------- hosts/microserver.home.ts.hillion.co.uk/image | 0 .../image | 0 4 files changed, 75 insertions(+), 62 deletions(-) create mode 100644 hosts/microserver.home.ts.hillion.co.uk/image create mode 100644 hosts/microserver.parents.ts.hillion.co.uk/image diff --git a/README.md b/README.md index 9e30df7..2be6ec8 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,7 @@ Raspberry Pi images that support Tailscale and headless SSH can be built using a command. It is easiest to run this command on AArch64 on Linux, such as within a Linux VM or Docker container on an M1 Mac. - docker run -v $PWD:/src -it --rm nixos/nix:latest /bin/sh - nix-env -f https://github.com/nix-community/nixos-generators/archive/master.tar.gz -i - cd /src - nixos-generate -f sd-aarch64-installer --system aarch64-linux -c hosts/microserver.home.ts.hillion.co.uk/default.nix - cp SOME_OUTPUT out.img.zst + $ docker run -v $PWD:/etc/nixos -it --rm nixos/nix:latest + # cd /etc/nixos + # nix build .#images.microserver.home.ts.hillion.co.uk diff --git a/flake.nix b/flake.nix index 3fa8d56..cc3b980 100644 --- a/flake.nix +++ b/flake.nix @@ -20,66 +20,81 @@ description = "Hillion Nix flake"; - outputs = { self, nixpkgs, nixpkgs-unstable, nixpkgs-chia, flake-utils, agenix, home-manager, impermanence, darwin, ... }@inputs: { - nixosConfigurations = - let - fqdns = builtins.attrNames (builtins.readDir ./hosts); - isNixos = fqdn: !builtins.pathExists ./hosts/${fqdn}/darwin; - getSystemOverlays = system: nixpkgsConfig: [ - (final: prev: { - "storj" = final.callPackage ./pkgs/storj.nix { }; - }) - ]; - mkHost = fqdn: - let system = builtins.readFile ./hosts/${fqdn}/system; - in - nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = inputs; - modules = [ - ./hosts/${fqdn}/default.nix - ./modules/default.nix + outputs = + { self, nixpkgs, nixpkgs-unstable, nixpkgs-chia, flake-utils, agenix, home-manager, impermanence, darwin, ... }@inputs: + let + fqdns = builtins.attrNames (builtins.readDir ./hosts); + isDarwin = host: builtins.pathExists ./hosts/${host}/darwin; + isNixos = fqdn: !isDarwin fqdn; + needsImage = fqdn: builtins.pathExists ./hosts/${fqdn}/image; + in + rec { + nixosConfigurations = + let + getSystemOverlays = system: nixpkgsConfig: [ + (final: prev: { + "storj" = final.callPackage ./pkgs/storj.nix { }; + }) + ]; + mkHost = fqdn: + let system = builtins.readFile ./hosts/${fqdn}/system; + in + nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = inputs; + modules = (if needsImage then [ ] else [ "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-raspberrypi.nix" ]) ++ [ + ./hosts/${fqdn}/default.nix + ./modules/default.nix - agenix.nixosModules.default - impermanence.nixosModules.impermanence + agenix.nixosModules.default + impermanence.nixosModules.impermanence - home-manager.nixosModules.default - { - home-manager.sharedModules = [ - impermanence.nixosModules.home-manager.impermanence - ]; - } + home-manager.nixosModules.default + { + home-manager.sharedModules = [ + impermanence.nixosModules.home-manager.impermanence + ]; + } - ({ config, ... }: { - nix.registry.nixpkgs.flake = nixpkgs; # pin `nix shell` nixpkgs - system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; - nixpkgs.overlays = getSystemOverlays config.nixpkgs.hostPlatform.system config.nixpkgs.config; - }) - ]; - }; - in - nixpkgs.lib.genAttrs (builtins.filter isNixos fqdns) mkHost; + ({ config, ... }: { + nix.registry.nixpkgs.flake = nixpkgs; # pin `nix shell` nixpkgs + system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; + nixpkgs.overlays = getSystemOverlays config.nixpkgs.hostPlatform.system config.nixpkgs.config; + }) + ]; + }; + in + nixpkgs.lib.genAttrs (builtins.filter isNixos fqdns) mkHost; - darwinConfigurations = - let - hosts = builtins.attrNames (builtins.readDir ./hosts); - isDarwin = host: builtins.pathExists ./hosts/${host}/darwin; - mkHost = host: - let system = builtins.readFile ./hosts/${host}/system; - in - darwin.lib.darwinSystem { - inherit system; - inherit inputs; - modules = [ - ./hosts/${host}/default.nix - agenix.darwinModules.default - home-manager.darwinModules.default - ]; - }; - in - nixpkgs.lib.genAttrs (builtins.filter isDarwin hosts) mkHost; + # images = + # let + # mkImage = fqdn: nixosConfigurations.${fqdn}.config.system.build.sdImage; + # in + # nixpkgs.lib.genAttrs (builtins.filter needsImage fqdns) mkImage; + + images = { + "microserver" = nixosConfigurations."microserver.home.ts.hillion.co.uk".config.system.build.sdImage; + }; - } // flake-utils.lib.eachDefaultSystem (system: { - formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt; - }); + darwinConfigurations = + let + hosts = builtins.attrNames (builtins.readDir ./hosts); + isDarwin = host: builtins.pathExists ./hosts/${host}/darwin; + mkHost = host: + let system = builtins.readFile ./hosts/${host}/system; + in + darwin.lib.darwinSystem { + inherit system; + inherit inputs; + modules = [ + ./hosts/${host}/default.nix + agenix.darwinModules.default + home-manager.darwinModules.default + ]; + }; + in + nixpkgs.lib.genAttrs (builtins.filter isDarwin hosts) mkHost; + } // flake-utils.lib.eachDefaultSystem (system: { + formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt; + }); } diff --git a/hosts/microserver.home.ts.hillion.co.uk/image b/hosts/microserver.home.ts.hillion.co.uk/image new file mode 100644 index 0000000..e69de29 diff --git a/hosts/microserver.parents.ts.hillion.co.uk/image b/hosts/microserver.parents.ts.hillion.co.uk/image new file mode 100644 index 0000000..e69de29