From 9c6dc59ff078241ab1b88057346f462ae32e6fc6 Mon Sep 17 00:00:00 2001 From: Evy Garden <evysgarden@protonmail.com> Date: Fri, 1 Dec 2023 15:00:56 +0100 Subject: [PATCH] add nix flake --- .envrc | 1 + .gitignore | 3 ++ flake.lock | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 36 +++++++++++++++++++++++ 4 files changed, 123 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 4864a1e..39aaa83 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ # rust target/ + +# direnv +.direnv/ \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1846e2c --- /dev/null +++ b/flake.lock @@ -0,0 +1,83 @@ +{ + "nodes": { + "naersk": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1698420672, + "narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=", + "owner": "nix-community", + "repo": "naersk", + "rev": "aeb58d5e8faead8980a807c840232697982d47b9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "master", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1701268161, + "narHash": "sha256-hL4jGGwMHHmyx6G9wi6IrYa8RLkoEtzCb4zWITH1B40=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "67be70a859530f6f7c358568eaa6ab0d84b36b01", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "naersk": "naersk", + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..3632c44 --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + description = "AoC 2023"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; + naersk = { + url = "github:nix-community/naersk/master"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, utils, naersk }: + utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + buildInputs = with pkgs; [ perl ]; + + naerskBuildPackage = (conf: ( + (pkgs.callPackage naersk { }).buildPackage ( + { + src = ./.; + inherit buildInputs; + } // conf + ) + )); + in + { + packages."01" = naerskBuildPackage { src = ./01/.; }; + + devShell = with pkgs; mkShell { + buildInputs = buildInputs ++ [ cargo rustc rustfmt rustPackages.clippy ]; + RUST_SRC_PATH = rustPlatform.rustLibSrc; + }; + }); +} -- GitLab