Add nix devshell for testing

This commit is contained in:
Agatha Lovelace 2023-06-07 21:24:47 +02:00
parent ba37df30c1
commit 3d1c38a5d0
Signed by: sorceress
GPG Key ID: 01D0B3AB10CED4F8
2 changed files with 36 additions and 5 deletions

View File

@ -10,8 +10,10 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: cachix/install-nix-action@v12 - uses: cachix/install-nix-action@v12
- name: Building package - name: Building package
run: nix-build . -A defaultPackage.x86_64-linux run: nix-build . -A packages.x86_64-linux.default
- name: Get commit hash
run: echo "COMMIT_HASH=${GITHUB_SHA::6}" >> $GITHUB_ENV
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
with: with:
name: url-eater-x86_64-linux name: eleanor-server-${{ env.COMMIT_HASH }}-x86_64-linux
path: result/bin/eleanor-server path: result/bin/eleanor-server

View File

@ -11,13 +11,13 @@
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
naersk-lib = pkgs.callPackage naersk { }; naersk-lib = pkgs.callPackage naersk { };
in { in {
defaultPackage = naersk-lib.buildPackage { packages.default = naersk-lib.buildPackage {
src = ./.; src = ./.;
nativeBuildInputs = with pkgs; [ pkg-config ]; nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ openssl ]; buildInputs = with pkgs; [ openssl ];
}; };
devShell = with pkgs; devShells = with pkgs; {
mkShell { default = mkShell {
buildInputs = [ buildInputs = [
openssl openssl
pkg-config pkg-config
@ -30,5 +30,34 @@
]; ];
RUST_SRC_PATH = rustPlatform.rustLibSrc; RUST_SRC_PATH = rustPlatform.rustLibSrc;
}; };
dev = mkShell {
buildInputs = [ openssl pkg-config cargo ];
shellHook = ''
testenv=$(mktemp -d --suffix "eleanor-server")
cargo build -Z unstable-options --out-dir $testenv
echo -e 'Built eleanor-server\n'
cd $testenv
cat << EOF >> settings.toml
port = 8008
[[sources]]
id = 0
path = "~/Music"
EOF
echo -e 'Generated settings.toml with source 0 pointing to `~/Music`\n'
./eleanor-server user add test password
echo -e '\nAdded user with credentials `test:password`\n'
echo -e 'Running eleanor-server\n'
exec ./eleanor-server
'';
};
};
}); });
} }