test cachix

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-05-07 03:53:38 +05:30
parent 25735e3581
commit cdf5c2bce6
3 changed files with 36 additions and 88 deletions

View File

@@ -31,12 +31,12 @@ resources:
uri: https://git.weirdnatto.in/natto1784/singh3.git
branch: master
- name: rust-image
- name: nix
type: registry-image
icon: docker
source:
repository: arm64v8/rust
tag: latest
repository: nixos/nix
tag: latest-arm64
jobs:
- name: configure-self
@@ -51,72 +51,30 @@ jobs:
- get: repo
trigger: true
passed: [configure-self]
- get: rust-image
- get: nix
trigger: false
- task: format
image: rust-image
config:
inputs:
- name: repo
platform: linux
run:
path: sh
args:
- -c
- |
rustup component add rustfmt
cargo fmt
dir: repo
- task: build
image: rust-image
image: nix
config:
params:
CARGO_HOME: cargo-home
CARGO_TARGET_DIR: builddir
CACHIX_NAME: ((cachix.name))
CACHIX_AUTH_TOKEN: ((cachix.token))
inputs:
- name: repo
caches:
- path: builddir
- path: cargo-home
platform: linux
run:
path: sh
args:
- -c
- |
cargo build --release --manifest-path repo/Cargo.toml
mkdir release
mv $CARGO_TARGET_DIR/release/singh3 bin
outputs:
- name: bin
- task: push-image
privileged: true
config:
platform: linux
image_resource:
type: registry-image
source:
repository: rdclda/concourse-oci-build-task
caches:
- path: cache
inputs:
- name: bin
outputs:
- name: image
run:
path: sh
args:
- -c
- |
cat <<EOF > Dockerfile
FROM arm64v8/ubuntu
COPY bin/singh3 /usr/bin/singh3
CMD ["singh3"]
EOF
build
nix-env -iA nixpkgs.cachix
cachix use $CACHIX_NAME
cachix watch-exec pain nix -- --extra-experimental-features "nix-command flakes" build ./repo
nix --extra-experimental-features "nix-command flakes" build ./repo#image -o result
nix-shell -p gzip --run "gzip -c $(readlink result) > final"
- put: image
params:
image: image/image.tar
image: final
- put: nomad-job
params:
job_path: repo/singh3.nomad

10
default.nix Normal file
View File

@@ -0,0 +1,10 @@
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
).defaultNix

View File

@@ -12,7 +12,6 @@
utils.lib.eachDefaultSystem
(system:
let
overlays =
[
(import "${cargo2nix}/overlay")
@@ -30,42 +29,23 @@
in
rec {
devShells = with pkgs; {
default = mkShell
{
devShell = with pkgs; mkShell {
buildInputs = [
rust-bin.nightly.latest.default
rust-analyzer
postgresql
];
};
withDB = mkShell
{
buildInputs = [
rust-bin.nightly.latest.default
postgresql
];
};
bare = mkShell
{
buildInputs = [
rust-bin.nightly.latest.default
];
};
withLSP = mkShell
{
buildInputs = [
rust-bin.nightly.latest.default
rust-analyzer
];
};
};
devShell = devShells.default;
packages = {
default = (rustPkgs.workspace.singh3 { }).bin;
image = pkgs.dockerTools.buildImage {
name = "singh3";
tag = "latest";
created = "now";
contents = packages.default;
config.Cmd = [ "/bin/singh3" ];
};
};
defaultPackage = packages.default;