From db86fe6244542b0f625855b071064e92260fff0b Mon Sep 17 00:00:00 2001 From: Joseph Hanson Date: Fri, 23 Feb 2024 15:36:14 -0600 Subject: [PATCH 1/4] Nix multi-platform. --- flake.lock | 72 ++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 20 +++++++++++- packages/default.nix | 28 +++++++++++++++++ 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 packages/default.nix diff --git a/flake.lock b/flake.lock index 464432c..d62c9ee 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,43 @@ { "nodes": { + "deploy-rs": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils" + }, + "locked": { + "lastModified": 1708091384, + "narHash": "sha256-dTGGw2y8wvfjr+J9CjQbfdulOq72hUG17HXVNxpH1yE=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "0a0187794ac7f7a1e62cda3dabf8dc041f868790", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "deploy-rs", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -113,6 +151,7 @@ }, "root": { "inputs": { + "deploy-rs": "deploy-rs", "home-manager": "home-manager", "nix-fast-build": "nix-fast-build", "nixpkgs": "nixpkgs", @@ -140,6 +179,21 @@ "type": "github" } }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ @@ -160,6 +214,24 @@ "repo": "treefmt-nix", "type": "github" } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 9e32a47..f74eb44 100644 --- a/flake.nix +++ b/flake.nix @@ -39,7 +39,24 @@ # The `@` syntax here is used to alias the attribute set of the # inputs's parameter, making it convenient to use inside the function. - outputs = { self, nixpkgs, home-manager, ... }@inputs: { + outputs = { self, nixpkgs, home-manager, ... }@inputs: + let + forAllSystems = nixpkgs.lib.genAttrs [ + "aarch64-linux" + "x86_64-linux" + ]; + in + { + pkgs = forAllSystems (localSystem: import nixpkgs { + inherit localSystem; + config = { + allowUnfree = true; + allowAliases = true; + }; + }); + + packages = forAllSystems (import ./packages inputs); + nixosConfigurations = { "durincore" = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; @@ -87,5 +104,6 @@ ]; }; }; + }; } diff --git a/packages/default.nix b/packages/default.nix new file mode 100644 index 0000000..fb20f68 --- /dev/null +++ b/packages/default.nix @@ -0,0 +1,28 @@ +{ + self, + nix-fast-build, + ... +}: +hostPlatform: + +let + inherit (self.pkgs.${hostPlatform}) callPackage lib linkFarm; + + nixosDrvs = lib.mapAttrs (_: nixos: nixos.config.system.build.toplevel) self.nixosConfigurations; + darwinDrvs = lib.mapAttrs (_: darwin: darwin.system) self.darwinConfigurations; + hostDrvs = nixosDrvs // darwinDrvs; + + compatHosts = lib.filterAttrs (_: host: host.hostPlatform == hostPlatform) self.hosts; + compatHostDrvs = lib.mapAttrs + (name: _: hostDrvs.${name}) + compatHosts; + + compatHostsFarm = linkFarm "hosts-${hostPlatform}" (lib.mapAttrsToList (name: path: { inherit name path; }) compatHostDrvs); +in +compatHostDrvs +// (lib.optionalAttrs (compatHosts != { }) { + default = compatHostsFarm; +}) // { + inherit (nix-fast-build.packages.${hostPlatform}) nix-fast-build; + inherit (self.pkgs.${hostPlatform}) cachix nix-eval-jobs; +} \ No newline at end of file From 532a01853b0ae3f83d0ef925f828eb67626c5c55 Mon Sep 17 00:00:00 2001 From: Joseph Hanson Date: Fri, 23 Feb 2024 15:54:03 -0600 Subject: [PATCH 2/4] Hosts and derivations. --- flake.nix | 1 + hosts.nix | 21 +++++++++++++++++++++ packages/default.nix | 12 +++++------- 3 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 hosts.nix diff --git a/flake.nix b/flake.nix index f74eb44..2332518 100644 --- a/flake.nix +++ b/flake.nix @@ -47,6 +47,7 @@ ]; in { + hosts = import ./hosts.nix; pkgs = forAllSystems (localSystem: import nixpkgs { inherit localSystem; config = { diff --git a/hosts.nix b/hosts.nix new file mode 100644 index 0000000..5248598 --- /dev/null +++ b/hosts.nix @@ -0,0 +1,21 @@ +{ + durincore = { + type = "nixos"; + hostPlatform = "x86_64-linux"; + pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBsUe5YF5z8vGcEYtQX7AAiw2rJygGf2l7xxr8nZZa7w"; + }; + gandalf = { + type = "nixos"; + address = "gandalf.jahanson.tech"; + hostPlatform = "x86_64-linux"; + pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBsUe5YF5z8vGcEYtQX7AAiw2rJygGf2l7xxr8nZZa7w"; + remoteBuild = true; + }; + este = { + type = "nixos"; + address = "este.jahanson.tech"; + hostPlatform = "x86_64-linux"; + pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBsUe5YF5z8vGcEYtQX7AAiw2rJygGf2l7xxr8nZZa7w"; + remoteBuild = true; + }; +} \ No newline at end of file diff --git a/packages/default.nix b/packages/default.nix index fb20f68..4e03594 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -6,23 +6,21 @@ hostPlatform: let - inherit (self.pkgs.${hostPlatform}) callPackage lib linkFarm; + inherit (self.pkgs."x86_64-linux") callPackage lib linkFarm; - nixosDrvs = lib.mapAttrs (_: nixos: nixos.config.system.build.toplevel) self.nixosConfigurations; - darwinDrvs = lib.mapAttrs (_: darwin: darwin.system) self.darwinConfigurations; - hostDrvs = nixosDrvs // darwinDrvs; + hostDrvs = lib.mapAttrs (_: nixos: nixos.config.system.build.toplevel) self.nixosConfigurations; compatHosts = lib.filterAttrs (_: host: host.hostPlatform == hostPlatform) self.hosts; compatHostDrvs = lib.mapAttrs (name: _: hostDrvs.${name}) compatHosts; - compatHostsFarm = linkFarm "hosts-${hostPlatform}" (lib.mapAttrsToList (name: path: { inherit name path; }) compatHostDrvs); + compatHostsFarm = linkFarm "hosts-x86_64-linux" (lib.mapAttrsToList (name: path: { inherit name path; }) compatHostDrvs); in compatHostDrvs // (lib.optionalAttrs (compatHosts != { }) { default = compatHostsFarm; }) // { - inherit (nix-fast-build.packages.${hostPlatform}) nix-fast-build; - inherit (self.pkgs.${hostPlatform}) cachix nix-eval-jobs; + inherit (nix-fast-build.packages."x86_64-linux") nix-fast-build; + inherit (self.pkgs."x86_64-linux") cachix nix-eval-jobs; } \ No newline at end of file From e29a574be101198e70f7822686a47f61757e55e2 Mon Sep 17 00:00:00 2001 From: Joseph Hanson Date: Mon, 26 Feb 2024 15:28:16 -0600 Subject: [PATCH 3/4] Update lock. --- flake.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index d62c9ee..33d2ec3 100644 --- a/flake.lock +++ b/flake.lock @@ -101,11 +101,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1708294118, - "narHash": "sha256-evZzmLW7qoHXf76VCepvun1esZDxHfVRFUJtumD7L2M=", + "lastModified": 1708831307, + "narHash": "sha256-0iL/DuGjiUeck1zEaL+aIe2WvA3/cVhp/SlmTcOZXH4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e0da498ad77ac8909a980f07eff060862417ccf7", + "rev": "5bf1cadb72ab4e77cb0b700dab76bcdaf88f706b", "type": "github" }, "original": { @@ -135,11 +135,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1708210246, - "narHash": "sha256-Q8L9XwrBK53fbuuIFMbjKvoV7ixfLFKLw4yV+SD28Y8=", + "lastModified": 1708819810, + "narHash": "sha256-1KosU+ZFXf31GPeCBNxobZWMgHsSOJcrSFA6F2jhzdE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "69405156cffbdf2be50153f13cbdf9a0bea38e49", + "rev": "89a2a12e6c8c6a56c72eb3589982c8e2f89c70ea", "type": "github" }, "original": { @@ -166,11 +166,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1708500294, - "narHash": "sha256-mvJIecY3tDKZh7297mqOtOuAvP7U1rqjfLNfmfkjFpU=", + "lastModified": 1708830076, + "narHash": "sha256-Cjh2xdjxC6S6nW6Whr2dxSeh8vjodzhTmQdI4zPJ4RA=", "owner": "Mic92", "repo": "sops-nix", - "rev": "f6b80ab6cd25e57f297fe466ad689d8a77057c11", + "rev": "2874fbbe4a65bd2484b0ad757d27a16107f6bc17", "type": "github" }, "original": { From b29beddeda211de14556cd2c5622b053ba402865 Mon Sep 17 00:00:00 2001 From: Joseph Hanson Date: Wed, 28 Feb 2024 20:46:00 -0600 Subject: [PATCH 4/4] Add lens and atuin. --- flake.lock | 12 ++++++------ home-manager/durincore.nix | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index 33d2ec3..3960e79 100644 --- a/flake.lock +++ b/flake.lock @@ -101,11 +101,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1708831307, - "narHash": "sha256-0iL/DuGjiUeck1zEaL+aIe2WvA3/cVhp/SlmTcOZXH4=", + "lastModified": 1708979614, + "narHash": "sha256-FWLWmYojIg6TeqxSnHkKpHu5SGnFP5um1uUjH+wRV6g=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5bf1cadb72ab4e77cb0b700dab76bcdaf88f706b", + "rev": "b7ee09cf5614b02d289cd86fcfa6f24d4e078c2a", "type": "github" }, "original": { @@ -166,11 +166,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1708830076, - "narHash": "sha256-Cjh2xdjxC6S6nW6Whr2dxSeh8vjodzhTmQdI4zPJ4RA=", + "lastModified": 1708987867, + "narHash": "sha256-k2lDaDWNTU5sBVHanYzjDKVDmk29RHIgdbbXu5sdzBA=", "owner": "Mic92", "repo": "sops-nix", - "rev": "2874fbbe4a65bd2484b0ad757d27a16107f6bc17", + "rev": "a1c8de14f60924fafe13aea66b46157f0150f4cf", "type": "github" }, "original": { diff --git a/home-manager/durincore.nix b/home-manager/durincore.nix index 5f5fbde..0800489 100644 --- a/home-manager/durincore.nix +++ b/home-manager/durincore.nix @@ -98,6 +98,7 @@ kubernetes-helm cilium-cli hubble + lens # misc fastfetch @@ -110,6 +111,7 @@ gawk zstd gnupg + fira-code-nerdfont # nix related # @@ -150,6 +152,7 @@ # Dev vscode termius + atuin ]; # starship - an customizable prompt for any shell