Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 18 additions & 30 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,53 +89,41 @@ build:source:

build:nix:
stage: build
image: nixos/nix
image: docker.nix-community.org/nixpkgs/cachix-flakes
needs: []
variables:
CACHIX_CACHE_NAME: villas

parallel:
matrix:
- SYSTEM: [x86_64-linux, aarch64-linux]

artifacts:
when: on_success
access: all
expire_in: "1 year"
paths:
- artifacts/villas
- artifacts/*

before_script:
- | # Create artifacts directory
mkdir artifacts

- | # Configure Nix
echo "experimental-features = flakes nix-command" >> /etc/nix/nix.conf

# - | # Configure Attic
# nix shell nixpgks#attic-client
- cachix use "$CACHIX_CACHE_NAME"

# attic login nulll https://cache.0l.de ${ATTIC_TOKEN}
# attic use "nulll:villas"
- | # Create directories
mkdir -p artifacts /var/tmp/

script:
- nix build --print-build-logs .

- | # Build ARX bundle
nix bundle --out-link villas .
cp -L villas artifacts/villas

- | # Build Docker image
- | # Login at Docker registry
nix run nixpkgs#skopeo -- login \
--username ${CI_REGISTRY_USER} \
--password ${CI_REGISTRY_PASSWORD} \
${CI_REGISTRY}

nix build '.#dockerImage'

nix run nixpkgs#skopeo -- copy --insecure-policy \
"docker-archive:./result" \
"docker://${DOCKER_IMAGE}:${DOCKER_TAG}-nix"

# after_script:
# - | # Push whole store to cache
# nix shell nixpgks#attic-client
script:
- cachix watch-exec $CACHIX_CACHE_NAME -- nix build --print-build-logs ".#villas-node-${SYSTEM}"
- cachix watch-exec $CACHIX_CACHE_NAME -- nix bundle --print-build-logs --out-link bundle ".#villas-node-${SYSTEM}"
- cachix watch-exec $CACHIX_CACHE_NAME -- nix build --print-build-logs --out-link docker ".#dockerImage-${SYSTEM}"

# attic push /nix/store/*
- cp -L bundle artifacts/villas-${SYSTEM}
- nix run nixpkgs#skopeo -- --tmpdir=${TMPDIR} --insecure-policy copy "docker-archive:./docker" "docker://${DOCKER_IMAGE}:${DOCKER_TAG}-nix-${SYSTEM}"

# Stage: test

Expand Down
30 changes: 30 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
{
description = "VILLASnode is a client/server application to connect simulation equipment and software.";

nixConfig = {
extra-substituters = [
"https://villas.cachix.org"
];
extra-trusted-public-keys = [
"villas.cachix.org-1:vCWp9IzwxFT6ovZivQAvn5ZuLST01bpAGXWwlGTZ9fA="
];
};

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
Expand Down Expand Up @@ -71,6 +80,27 @@
config.ENTRYPOINT = "/bin/villas";
};

# Cross-compiled packages

villas-node-x86_64-linux = if pkgs.system == "x86_64-linux" then pkgs.villas-node else pkgs.pkgsCross.x86_64-linux.villas-node;
villas-node-aarch64-linux = if pkgs.system == "aarch64-linux" then pkgs.villas-node else pkgs.pkgsCross.aarch64-multiplatform.villas-node;

dockerImage-x86_64-linux = pkgs.dockerTools.buildLayeredImage {
name = "villas-node";
tag = "latest-nix-x86_64-linux";
contents = [ villas-node-x86_64-linux ];
config.ENTRYPOINT = "/bin/villas";
};

dockerImage-aarch64-linux = pkgs.dockerTools.buildLayeredImage {
name = "villas-node";
tag = "latest-nix-aarch64-linux";
contents = [ villas-node-aarch64-linux ];
config.ENTRYPOINT = "/bin/villas";
};

# Third-party dependencies

opendssc = pkgs.callPackage (nixDir + "/opendssc.nix") { };
};
in
Expand Down
3 changes: 2 additions & 1 deletion packaging/nix/villas.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# Node-types
withNodeAmqp ? withAllNodes,
withNodeComedi ? withAllNodes,
withNodeEthercat ? withAllNodes,
withNodeEthercat ? (withAllNodes && system == "x86_64-linux"),
withNodeIec60870 ? withAllNodes,
withNodeIec61850 ? withAllNodes,
withNodeInfiniband ? withAllNodes,
Expand All @@ -42,6 +42,7 @@
jq,
lib,
makeWrapper,
system,
pkg-config,
stdenv,
# Optional dependencies
Expand Down