fdb820602b
To reproduce:
$ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
-- scan --update-all --inline-rules '
id: nix-x86_64-darwin
language: nix
rule:
any:
- pattern: "\"x86_64-darwin\""
kind: list_expression > string_expression
- pattern:
context: "{ \"x86_64-darwin\" = $EXPR; }"
selector: binding
- pattern:
context: "{ x86_64-darwin = $EXPR; }"
selector: binding
fix:
template: ""
' pkgs
$ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
-- scan --update-all --inline-rules '
id: json-first-x86_64-darwin
language: json
rule:
kind: object > pair:nth-child(1)
has:
pattern: "\"x86_64-darwin\""
field: key
fix:
template: ""
expandEnd: { regex: "," }
' pkgs
$ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
-- scan --update-all --inline-rules '
id: json-x86_64-darwin
language: json
rule:
kind: object > pair
has:
pattern: "\"x86_64-darwin\""
field: key
fix:
template: ""
expandStart: { regex: "," }
' pkgs
$ git restore pkgs/by-name/om/omnix/package.nix
$ git diff --name-only -z \
| nix shell nixpkgs/3b32825de172d0bc85664f495edb096b10862524#gnused \
-c xargs -0 sed -i '/^$/N; /^\n\? \+$/d'
$ treefmt
115 lines
2.5 KiB
Nix
115 lines
2.5 KiB
Nix
{
|
|
lib,
|
|
channel ? "stable",
|
|
fetchurl,
|
|
installShellFiles,
|
|
makeBinaryWrapper,
|
|
terraform,
|
|
stdenvNoCC,
|
|
unzip,
|
|
nixosTests,
|
|
}:
|
|
|
|
let
|
|
inherit (stdenvNoCC.hostPlatform) system;
|
|
|
|
channels = {
|
|
stable = {
|
|
version = "2.33.11";
|
|
hash = {
|
|
x86_64-linux = "sha256-NY9xyLc6Pr1wWPnr4fLo6t+7B7Gin/BlTH3tdxQk30k=";
|
|
aarch64-linux = "sha256-Wc9hhotJKcb1fdjfh9pWxVs/e4YpBua1PyAhMRJbUAY=";
|
|
aarch64-darwin = "sha256-7A6BxOg4A3Ua5SXjnh5gtG/LE94iGuRQPe/S9UjX/oc=";
|
|
};
|
|
};
|
|
mainline = {
|
|
version = "2.34.5";
|
|
hash = {
|
|
x86_64-linux = "sha256-B0roCJqTu6o89nHbVA3b9eHKj/VmJ9i1j4blF1I76yU=";
|
|
aarch64-linux = "sha256-UDyEhBAlvgSHWLPtbNXHj6X2gle1Y3fjQLSKHzwc/XI=";
|
|
aarch64-darwin = "sha256-VhliikNdqi7AauYlKQvMroEjR3jZZnhNw0HTtJFw5zg=";
|
|
};
|
|
};
|
|
};
|
|
in
|
|
stdenvNoCC.mkDerivation (finalAttrs: {
|
|
pname = "coder";
|
|
version = channels.${channel}.version;
|
|
src = fetchurl {
|
|
hash = (channels.${channel}.hash).${system};
|
|
|
|
url =
|
|
let
|
|
systemName =
|
|
{
|
|
x86_64-linux = "linux_amd64";
|
|
aarch64-linux = "linux_arm64";
|
|
aarch64-darwin = "darwin_arm64";
|
|
}
|
|
.${system};
|
|
|
|
ext =
|
|
{
|
|
x86_64-linux = "tar.gz";
|
|
aarch64-linux = "tar.gz";
|
|
aarch64-darwin = "zip";
|
|
}
|
|
.${system};
|
|
in
|
|
"https://github.com/coder/coder/releases/download/v${finalAttrs.version}/coder_${finalAttrs.version}_${systemName}.${ext}";
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
installShellFiles
|
|
makeBinaryWrapper
|
|
unzip
|
|
];
|
|
|
|
unpackPhase = ''
|
|
runHook preUnpack
|
|
|
|
case $src in
|
|
*.tar.gz) tar -xz -f "$src" ;;
|
|
*.zip) unzip "$src" ;;
|
|
esac
|
|
|
|
runHook postUnpack
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
install -D -m755 coder $out/bin/coder
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
postInstall = ''
|
|
wrapProgram $out/bin/coder \
|
|
--prefix PATH : ${lib.makeBinPath [ terraform ]}
|
|
'';
|
|
|
|
# integration tests require network access
|
|
doCheck = false;
|
|
|
|
meta = {
|
|
description = "Provision remote development environments via Terraform";
|
|
homepage = "https://coder.com";
|
|
license = lib.licenses.agpl3Only;
|
|
mainProgram = "coder";
|
|
maintainers = with lib.maintainers; [
|
|
bpmct
|
|
developmentcats
|
|
kylecarbs
|
|
phorcys420
|
|
];
|
|
};
|
|
|
|
passthru = {
|
|
updateScript = ./update.sh;
|
|
tests = {
|
|
inherit (nixosTests) coder;
|
|
};
|
|
};
|
|
})
|