nix setup

This commit is contained in:
Robin Appelman 2024-03-17 16:45:57 +01:00
commit 33e005b545
7 changed files with 138 additions and 2 deletions

3
.env Normal file
View file

@ -0,0 +1,3 @@
DB_URL=postgres://postgres:test@localhost:15432/postgres
BASE_URL=http://localhost:8888
EDIT_KEY=edit

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

7
.gitignore vendored
View file

@ -1,2 +1,5 @@
/target
.env
target
result
.direnv
config.toml
data/*

60
flake.lock generated Normal file
View file

@ -0,0 +1,60 @@
{
"nodes": {
"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"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1708529342,
"narHash": "sha256-gTzSstZWvAJgVz5U6coxVtAlY7dldPKgljjR9+cGr/I=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "700804df18b73e2fe360d950f371aaec1691dea2",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "release-23.11",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"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
}

42
flake.nix Normal file
View file

@ -0,0 +1,42 @@
{
inputs = {
nixpkgs.url = "nixpkgs/release-23.11";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (system: let
overlays = [
(import ./overlay.nix)
];
pkgs = (import nixpkgs) {
inherit system overlays;
};
tools = with pkgs; [
rustc
cargo
bacon
cargo-edit
cargo-outdated
clippy
cargo-audit
cargo-msrv
];
dependencies = with pkgs; [
openssl
pkg-config
];
in rec {
packages = rec {
inherit (pkgs) demostf-api-test;
default = demostf-api-test;
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = tools ++ dependencies;
};
});
}

3
overlay.nix Normal file
View file

@ -0,0 +1,3 @@
prev: final: {
demostf-api-test = final.callPackage ./package.nix {};
}

24
package.nix Normal file
View file

@ -0,0 +1,24 @@
{
rustPlatform,
lib,
pkg-config,
openssl,
}: let
inherit (lib.sources) sourceByRegex;
in
rustPlatform.buildRustPackage rec {
pname = "demostf-api-test";
version = "0.1.0";
src = sourceByRegex ./. ["Cargo.*" "(src|data)(/.*)?"];
buildInputs = [openssl];
nativeBuildInputs = [pkg-config];
doCheck = false;
cargoLock = {
lockFile = ./Cargo.lock;
};
}