Last active
August 3, 2023 15:24
-
-
Save drupol/e6c8a388e6e6b46fdf95d31880f4aa97 to your computer and use it in GitHub Desktop.
Playing with Nix on Gitlab CI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/nixos/nix:2.17.0 | |
variables: | |
COMPOSER_ALLOW_SUPERUSER: 1 | |
default: | |
before_script: | |
- echo experimental-features = nix-command flakes >> /etc/nix/nix.conf | |
- echo access-tokens = github.com=${GITHUB_TOKEN} >> /etc/nix/nix.conf | |
- | | |
cat > flake.nix << EOF | |
{ | |
description = "Gitlab CI devshell"; | |
inputs = { | |
nixpkgs.url = "github:NixOS/nixpkgs/4b0ef51702e1512880179cd24e9e63b88f0a2121"; | |
}; | |
outputs = inputs@{ self, flake-parts, ... }: | |
flake-parts.lib.mkFlake { inherit inputs; } { | |
systems = [ "x86_64-linux" ]; | |
perSystem = { config, pkgs, system, ... }: | |
let | |
php = pkgs.php.withExtensions ({ enabled, all }: enabled ++ [ all.xsl all.pcov ]); | |
in | |
{ | |
packages.default = pkgs.buildEnv { | |
name = "gitlab-ci"; | |
paths = [ | |
php | |
php.packages.composer | |
pkgs.nodePackages.prettier | |
]; | |
}; | |
}; | |
}; | |
} | |
EOF | |
- git add . | |
- nix profile install . | |
stages: | |
- test | |
Unit tests: | |
stage: test | |
script: | |
- composer install | |
- composer grumphp | |
Prettier checks: | |
stage: test | |
script: | |
- prettier --check . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment