diff --git a/README.md b/README.md index 45b47d2..8ce6546 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ ## TODO - [x] Use timeout for fetching departures -- [ ] Write ESP8266 client - [x] Add basic auth -- [ ] Create Nix package -- [ ] Create container +- [x] Create Nix package +- [x] Create container +- [ ] Write ESP8266 client +- [ ] Make port configurable diff --git a/flake.lock b/flake.lock index f1034b0..7d916e8 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,25 @@ { "nodes": { + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1720957393, @@ -18,6 +38,7 @@ }, "root": { "inputs": { + "gitignore": "gitignore", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 41625c4..9d009f3 100644 --- a/flake.nix +++ b/flake.nix @@ -3,17 +3,51 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + gitignore = { + url = "github:hercules-ci/gitignore.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs }: + outputs = { self, nixpkgs, gitignore }: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; + + vrnp-static = pkgs.buildGoModule { + pname = "vrnp"; + version = "0.0.0"; + vendorHash = null; + + # For building the package, we use only the files not ignored by Git as inputs. + # Also, flake.nix and flake.lock are not included to avoid annoying rebuilds when + # working on them. + src = pkgs.lib.cleanSourceWith { + src = gitignore.lib.gitignoreSource ./.; + filter = path: type: builtins.baseNameOf path != "flake.nix" && builtins.baseNameOf path != "flake.lock"; + }; + + # Avoid linking against libc + CGO_ENABLED = 0; + }; in { devShell.${system} = pkgs.mkShellNoCC { packages = [ pkgs.go ]; }; + packages.${system} = { + default = vrnp-static; + docker = pkgs.dockerTools.buildImage { + name = "git.pbrinkmeier.de/paul/vrnp"; + tag = vrnp-static.version; + copyToRoot = pkgs.buildEnv { + name = "vrnp-root"; + paths = [ vrnp-static pkgs.cacert ]; + pathsToLink = [ "/bin" "/etc" ]; + }; + config.Cmd = [ "${vrnp-static}/bin/vrnp" ]; + }; + }; }; }