From 1b2528f9c4fb131eafde04a33958fe54cdee3183 Mon Sep 17 00:00:00 2001 From: corentin Date: Fri, 19 Jan 2024 17:04:22 +0000 Subject: [PATCH] Add nixos config (!8) flake.lock is as important as cargo.lock Reviewed-on: https://git.tipragot.fr/corentin/border-wars/pulls/8 Co-authored-by: corentin Co-committed-by: corentin --- .gitignore | 3 ++ flake.lock | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 49 ++++++++++++++++++++++ 3 files changed, 172 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index ea8c4bf..6adb4e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ /target +/result +/result-lib +.direnv \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3f23736 --- /dev/null +++ b/flake.lock @@ -0,0 +1,120 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1705559032, + "narHash": "sha256-Cb+Jd1+Gz4Wi+8elPnUIHnqQmE1qjDRZ+PsJaPaAffY=", + "owner": "nix-community", + "repo": "fenix", + "rev": "e132ea0eb0c799a2109a91688e499d7bf4962801", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1698420672, + "narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=", + "owner": "nmattia", + "repo": "naersk", + "rev": "aeb58d5e8faead8980a807c840232697982d47b9", + "type": "github" + }, + "original": { + "owner": "nmattia", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1705600018, + "narHash": "sha256-Q6Ly22/o0AQM6prXh2LciVNAc5OKHAMpIaEHslzyMnQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "3df632c2fba47c5d477f498b02add5c7aa2126f3", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "flake-utils": "flake-utils", + "naersk": "naersk", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1705523001, + "narHash": "sha256-TWq5vJ6m+9HGSDMsQAmz1TMegMi79R3TTyKjnPWsQp8=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "9d9b34354d2f13e33568c9c55b226dd014a146a0", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "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" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ab52923 --- /dev/null +++ b/flake.nix @@ -0,0 +1,49 @@ +{ + description = "An online turn based game"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs"; + flake-utils = { + url = "github:numtide/flake-utils"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + naersk = { + url = "github:nmattia/naersk"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, fenix, naersk, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + + toolchain = fenix.packages.${system}.complete; + + naersk-lib = naersk.lib.${system}.override { + inherit (toolchain) cargo rustc; + }; + + border-wars = naersk-lib.buildPackage { + name = "border-wars"; + src = ./.; + }; + in { + packages.border-wars = border-wars; + defaultPackage = self.packages.${system}.border-wars; + + devShell = pkgs.mkShell { + inputsFrom = builtins.attrValues self.packages.${system}; + nativeBuildInputs = [ + (toolchain.withComponents [ + "cargo" "rustc" "rust-src" "rustfmt" "clippy" + ]) + ]; + RUST_BACKTRACE = 0; + }; + }); +} \ No newline at end of file