From 4f369457e8f5d8524d93cfaf9d28e311d501a3f6 Mon Sep 17 00:00:00 2001 From: Noa Aarts Date: Wed, 20 Nov 2024 22:02:51 +0100 Subject: [PATCH] add flake for nix --- .gitignore | 4 ++++ flake.lock | 27 ++++++++++++++++++++++++++ flake.nix | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index ea8c4bf..42dda0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ /target + +/.direnv +/result +/.envrc diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1720cb2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1732014248, + "narHash": "sha256-y/MEyuJ5oBWrWAic/14LaIr/u5E0wRVzyYsouYY3W6w=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "23e89b7da85c3640bbc2173fe04f4bd114342367", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b2ff6a4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,57 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; + + outputs = + { nixpkgs, ... }: + let + allSystems = [ + "x86_64-linux" # 64-bit Intel/AMD Linux + "aarch64-linux" # 64-bit ARM Linux + "x86_64-darwin" # 64-bit Intel macOS + "aarch64-darwin" # 64-bit ARM macOS + ]; + forAllSystems = + f: + nixpkgs.lib.genAttrs allSystems ( + system: + f { + inherit system; + pkgs = import nixpkgs { inherit system; }; + } + ); + in + { + packages = forAllSystems ( + { pkgs, ... }: + rec { + default = webby; + webby = pkgs.rustPlatform.buildRustPackage { + pname = "webby"; + version = "0.1.0"; + cargoLock.lockFile = ./Cargo.lock; + src = pkgs.lib.fileset.toSource { + root = ./.; + fileset = pkgs.lib.fileset.unions [ + ./Cargo.lock + ./Cargo.toml + ./src + ]; + }; + }; + } + ); + devShells = forAllSystems ( + { pkgs, system, ... }: + { + default = pkgs.mkShell { + buildInputs = [ + pkgs.cargo + pkgs.clippy + ]; + }; + } + ); + }; +}