mirror of
https://github.com/Smaug123/AdventOfCode2022
synced 2025-10-08 19:18:40 +00:00
Flake (#43)
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1,3 +1,4 @@
|
||||
* text=auto
|
||||
*.sh text=lf
|
||||
*.txt text=lf
|
||||
*.nix text=lf
|
||||
|
121
flake.lock
generated
Normal file
121
flake.lock
generated
Normal file
@@ -0,0 +1,121 @@
|
||||
{
|
||||
"nodes": {
|
||||
"alejandra": {
|
||||
"inputs": {
|
||||
"fenix": "fenix",
|
||||
"flakeCompat": "flakeCompat",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1660510326,
|
||||
"narHash": "sha256-xFumnivtVwu5fFBOrTxrv6fv3geHKF04RGP23EsDVaI=",
|
||||
"owner": "kamadorueda",
|
||||
"repo": "alejandra",
|
||||
"rev": "ef03f7ef74ec97fd91a016a51c9c9667fb315652",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "kamadorueda",
|
||||
"ref": "3.0.0",
|
||||
"repo": "alejandra",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"fenix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"alejandra",
|
||||
"nixpkgs"
|
||||
],
|
||||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1657607339,
|
||||
"narHash": "sha256-HaqoAwlbVVZH2n4P3jN2FFPMpVuhxDy1poNOR7kzODc=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "b814c83d9e6aa5a28d0cf356ecfdafb2505ad37d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flakeCompat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1650374568,
|
||||
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1671548329,
|
||||
"narHash": "sha256-OrC6R6zihRjFqdKFF3/vD3bkz44poONSII8ncre1Wh0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ba6ba2b90096dc49f448aa4d4d783b5081b1cc87",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"alejandra": "alejandra",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1657557289,
|
||||
"narHash": "sha256-PRW+nUwuqNTRAEa83SfX+7g+g8nQ+2MMbasQ9nt6+UM=",
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "caf23f29144b371035b864a1017dbc32573ad56d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "rust-lang",
|
||||
"ref": "nightly",
|
||||
"repo": "rust-analyzer",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
68
flake.nix
Normal file
68
flake.nix
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
description = "Advent of Code 2022";
|
||||
|
||||
inputs = {
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
|
||||
alejandra.url = "github:kamadorueda/alejandra/3.0.0";
|
||||
alejandra.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
alejandra,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
projectFile = "./AdventOfCode2022.App/AdventOfCode2022.App.fsproj";
|
||||
pname = "AdventOfCode2022";
|
||||
outputFiles = [""];
|
||||
arrayToShell = a: toString (map (pkgs.lib.escape (pkgs.lib.stringToCharacters "\\ ';$`()|<>\t")) a);
|
||||
in {
|
||||
packages = {
|
||||
default = pkgs.buildDotnetPackage {
|
||||
pname = pname;
|
||||
version = "0.0.1";
|
||||
src = ./.;
|
||||
projectFile = projectFile;
|
||||
buildInputs = [
|
||||
pkgs.dotnet-sdk_7
|
||||
# unit tests
|
||||
pkgs.dotnetPackages.NUnit
|
||||
pkgs.dotnetPackages.NUnitRunners
|
||||
];
|
||||
outputFiles = outputFiles;
|
||||
exeFiles = ["AdventOfCode2022.App"];
|
||||
nativeBuildInputs = [
|
||||
pkgs.pkg-config
|
||||
];
|
||||
buildPhase = ''runHook preBuild && dotnet publish --configuration Release ${projectFile} && runHook postBuild'';
|
||||
doCheck = true;
|
||||
checkPhase = ''runHook preCheck && dotnet test --configuration Debug && dotnet test --configuration Release && runHook postCheck'';
|
||||
installPhase = builtins.readFile (pkgs.substituteAll {
|
||||
src = ./install.sh;
|
||||
outputFiles = arrayToShell outputFiles;
|
||||
pname = pname;
|
||||
dllPatterns = arrayToShell ["*.dll"];
|
||||
dotnet = pkgs.dotnet-sdk_7;
|
||||
exePattern = arrayToShell ["AdventOfCode2022.App"];
|
||||
});
|
||||
};
|
||||
};
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
(with dotnetCorePackages;
|
||||
combinePackages [
|
||||
dotnet-sdk_7
|
||||
dotnetPackages.Nuget
|
||||
])
|
||||
];
|
||||
packages = [
|
||||
alejandra.defaultPackage.${system}
|
||||
];
|
||||
};
|
||||
});
|
||||
}
|
18
install.sh
Normal file
18
install.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
runHook preInstall
|
||||
target="${out:?}/lib/dotnet/@pname@"
|
||||
mkdir -p "$target"
|
||||
cp -rv @outputFiles@ AdventOfCode2022.App/bin/Release/net7.0/publish/* "$target"
|
||||
pushd "$out" || exit 1
|
||||
remove-duplicated-dlls.sh
|
||||
popd || exit 2
|
||||
set -f
|
||||
exe="$target/AdventOfCode2022.App"
|
||||
[ -f "$exe" ] || exit 3
|
||||
mkdir -p "$out"/bin
|
||||
commandName="$(basename -s .exe "$(echo "$exe" | tr "[:upper:]" "[:lower:]")")"
|
||||
makeWrapper \
|
||||
"$exe" \
|
||||
"$out/bin/$commandName"
|
||||
|
||||
runHook postInstall
|
Reference in New Issue
Block a user