Set up Cargo and Nix project
This commit is contained in:
parent
4e82f47f90
commit
34855f3b7b
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/target
|
||||
/.direnv
|
||||
/.env
|
||||
/.yoi
|
||||
/result
|
||||
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "decodal"
|
||||
version = "0.1.0"
|
||||
6
Cargo.toml
Normal file
6
Cargo.toml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[package]
|
||||
name = "decodal"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
15
devshell.nix
Normal file
15
devshell.nix
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{ pkgs }:
|
||||
pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
cargo
|
||||
clippy
|
||||
git
|
||||
nixfmt
|
||||
rustc
|
||||
rustfmt
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
echo "decodal dev shell"
|
||||
'';
|
||||
}
|
||||
61
flake.lock
Normal file
61
flake.lock
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1781074563,
|
||||
"narHash": "sha256-md8WlXOlfnIeHeOScMTTHFyf2d6iaTwPl2apR5EQ3P4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9ae611a455b90cf061d8f332b977e387bda8e1ca",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"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
|
||||
}
|
||||
38
flake.nix
Normal file
38
flake.nix
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
description = "Decodal - Deferred Constraint Data Language";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
decodal = pkgs.callPackage ./package.nix { };
|
||||
mkApp = name: description: {
|
||||
type = "app";
|
||||
program = "${decodal}/bin/${name}";
|
||||
meta.description = description;
|
||||
};
|
||||
in
|
||||
{
|
||||
packages.default = decodal;
|
||||
packages.decodal = decodal;
|
||||
|
||||
apps.default = mkApp "decodal" "Run Decodal";
|
||||
apps.decodal = mkApp "decodal" "Run Decodal";
|
||||
|
||||
checks.default = decodal;
|
||||
|
||||
devShells.default = import ./devshell.nix { inherit pkgs; };
|
||||
}
|
||||
);
|
||||
}
|
||||
54
package.nix
Normal file
54
package.nix
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
lib,
|
||||
rustPlatform,
|
||||
}:
|
||||
|
||||
let
|
||||
srcRoot = ./.;
|
||||
srcRootString = toString srcRoot;
|
||||
sourceFilter =
|
||||
path: type:
|
||||
let
|
||||
pathString = toString path;
|
||||
relPath = lib.removePrefix "${srcRootString}/" pathString;
|
||||
baseName = baseNameOf pathString;
|
||||
isExcludedTree = dir: relPath == dir || lib.hasPrefix "${dir}/" relPath;
|
||||
in
|
||||
!(
|
||||
baseName == ".git"
|
||||
|| baseName == "target"
|
||||
|| baseName == "result"
|
||||
|| isExcludedTree ".yoi"
|
||||
|| isExcludedTree ".worktree"
|
||||
);
|
||||
in
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "decodal";
|
||||
version = "0.1.0";
|
||||
|
||||
src = lib.cleanSourceWith {
|
||||
src = srcRoot;
|
||||
filter = sourceFilter;
|
||||
};
|
||||
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
doInstallCheck = true;
|
||||
installCheckPhase = ''
|
||||
runHook preInstallCheck
|
||||
|
||||
test -x "$out/bin/decodal"
|
||||
"$out/bin/decodal" >/dev/null
|
||||
|
||||
runHook postInstallCheck
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Deferred Constraint Data Language";
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "decodal";
|
||||
platforms = lib.platforms.unix;
|
||||
};
|
||||
}
|
||||
3
src/main.rs
Normal file
3
src/main.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user