Verified Commit f2310f69 authored by Hugo Moreau's avatar Hugo Moreau
Browse files

nix: add go2pins package

parent 2d087c6f
Pipeline #32548 passed with stage
in 2 minutes and 34 seconds
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1631561581,
"narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"futils": {
"locked": {
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1641229786,
"narHash": "sha256-WPPcLNbVu6ryj772GooUpF285LOvRHdOo/UNJgPnFYI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "88579effa7e88c25087faf6de6388d0cd1738dc0",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-21.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1635719588,
"narHash": "sha256-pWjdy0NheM97NsPE6+jUnr5LYyeA0sBGTdw4mfXMGZQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f0869b1a2c0b150aac26e10bb5c2364ffb2e804f",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-21.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"futils": "futils",
"nixpkgs": "nixpkgs",
"spot": "spot"
}
},
"spot": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1641304747,
"narHash": "sha256-e0tOHGgexBzvsfTkp0fZ8KFj9lQwCBne1+VMVrrBwcA=",
"ref": "am/nix",
"rev": "fd1f03f7490a11fd44efc7d6f44ad753223e1298",
"revCount": 6134,
"type": "git",
"url": "ssh://git@gitlab.lrde.epita.fr/spot/spot.git"
},
"original": {
"ref": "am/nix",
"type": "git",
"url": "ssh://git@gitlab.lrde.epita.fr/spot/spot.git"
}
}
},
"root": "root",
"version": 7
}
{
description = "Go2Pins";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05";
futils.url = "github:numtide/flake-utils";
spot.url = "git+ssh://git@gitlab.lrde.epita.fr/spot/spot.git?ref=am/nix";
};
outputs = { self, nixpkgs, futils, spot, ... }:
futils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
spotpkgs = spot.packages.${system};
go2pinsPackage = { lib, pkgs, fetchgit, buildGoModule, ... }:
buildGoModule rec {
pname = "go2pins";
version = "0.1b";
src = self;
buildInputs = with spotpkgs; [
spotFull
];
vendorSha256 = "Y4ZwxwbGAlea/k2aS94P4c3dG2SyBcHMp/OgGafnmKE=";
patches = [ ./runtime.patch ];
subPackages = [ "." ];
postBuild = ''
go build -ldflags "-s -w"
go build -o ltlrec ltl/desugar/main.go
'';
installPhase = ''
mkdir -p $out/pkg/mod/gitlab.lrde.epita.fr/spot/
cp -r $PWD $out/pkg/mod/gitlab.lrde.epita.fr/spot/${pname}@${version}
mkdir -p $out/bin
ln -s $out/pkg/mod/gitlab.lrde.epita.fr/spot/${pname}@${version}/go2pins $out/bin/go2pins
ln -s $out/pkg/mod/gitlab.lrde.epita.fr/spot/${pname}@${version}/ltlrec $out/bin/ltlrec
'';
doCheck = false;
meta = with lib; {
description = "Go2Pins: a Golang-to-Golang transpiler";
homepage = "https://gitlab.lrde.epita.fr/spot/${pname}";
changelog = "https://gitlab.lrde.epita.fr/spot/${pname}/-/raw/master/ChangeLog";
license = licenses.gpl3;
maintainers = [ maintainer.ryukizo ];
};
};
in
{
packages = {
go2pins = pkgs.callPackage go2pinsPackage { };
};
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
go
spotpkgs.spotFull
self.packages.${system}.go2pins
];
};
}
);
}
diff --git a/main.go b/main.go
index 5099a76..1ba0cda 100644
--- a/main.go
+++ b/main.go
@@ -33,7 +33,6 @@ import (
"os/exec"
"path"
"regexp"
- "runtime"
"strconv"
"strings"
"text/template"
@@ -612,9 +611,8 @@ func main() {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
- // Get project root directory to locate boilerplate/ dir
- _, currentPath, _, ok := runtime.Caller(0)
- if !ok {
+ currentPath, err := os.Executable()
+ if err != nil {
fmt.Fprintln(os.Stderr, "can't get path of current file")
os.Exit(1)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment