From 8e5729eef4fde126b0318564f225e99d3cda5be2 Mon Sep 17 00:00:00 2001 From: "@crashkeys.dev" Date: Tue, 4 Nov 2025 12:23:10 +0100 Subject: [PATCH] nix: Initial flake setup. --- .gitignore | 1 + flake.lock | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 49 ++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index ea8c4bf..07c12f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..22f760f --- /dev/null +++ b/flake.lock @@ -0,0 +1,87 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "naersk", + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1752475459, + "narHash": "sha256-z6QEu4ZFuHiqdOPbYss4/Q8B0BFhacR8ts6jO/F/aOU=", + "owner": "nix-community", + "repo": "fenix", + "rev": "bf0d6f70f4c9a9cf8845f992105652173f4b617f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "naersk": { + "inputs": { + "fenix": "fenix", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1752689277, + "narHash": "sha256-uldUBFkZe/E7qbvxa3mH1ItrWZyT6w1dBKJQF/3ZSsc=", + "owner": "nix-community", + "repo": "naersk", + "rev": "0e72363d0938b0208d6c646d10649164c43f4d64", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1762111121, + "narHash": "sha256-4vhDuZ7OZaZmKKrnDpxLZZpGIJvAeMtK6FKLJYUtAdw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b3d51a0365f6695e7dd5cdf3e180604530ed33b4", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "naersk": "naersk", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1752428706, + "narHash": "sha256-EJcdxw3aXfP8Ex1Nm3s0awyH9egQvB2Gu+QEnJn2Sfg=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "591e3b7624be97e4443ea7b5542c191311aa141d", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..dc7e3f6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,49 @@ +{ + description = "Personal website flake."; + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + naersk.url = "github:nix-community/naersk"; + naersk.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, naersk }: + let + supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + in + { + packages = forAllSystems (system: + let + pkgs = (import nixpkgs) { + inherit system; + }; + cargo-toml = builtins.fromTOML (builtins.readFile ./Cargo.toml); + naersk' = pkgs.callPackage naersk {}; + app = naersk'.buildPackage { + src = ./.; + }; + in { + default = app; + docker = pkgs.dockerTools.streamLayeredImage { + name = "localhost/${cargo-toml.package.name}"; + tag = "latest"; + contents = [ app pkgs.bash ]; + config.Cmd = [ "${app}/bin/${cargo-toml.package.name}" ]; + }; + }); + + # For `nix develop` (optional, can be skipped): + devShells = + forAllSystems (system: + let + pkgs = (import nixpkgs) { + inherit system; + }; + in + { + default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ rustc cargo jujutsu ]; + }; + }); + }; +} -- 2.51.2