diff --git a/.gitignore b/.gitignore index a474720..00b4b91 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ astartectl astartectl_* .gobuild dist/ +/result # Direnv .direnv/ diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..084cbf5 --- /dev/null +++ b/default.nix @@ -0,0 +1 @@ +(import .nix/flake-compat.nix).defaultNix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1a33247 --- /dev/null +++ b/flake.lock @@ -0,0 +1,98 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "go-utils": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1690384468, + "narHash": "sha256-52TpCs2La0HFnigiBW/CdxzlOFWra34e+xz0iQrgpbU=", + "owner": "noaccOS", + "repo": "go-utils", + "rev": "18532d9340d4e7841eba4ed3b50ca12516ab679b", + "type": "github" + }, + "original": { + "owner": "noaccOS", + "repo": "go-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1690327932, + "narHash": "sha256-Fv7PYZxN4eo0K6zXhHG/vOc+e2iuqQ5ywDrh0yeRjP0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a9b47d85504bdd199e90846622c76aa0bfeabfac", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixpkgs-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "go-utils": "go-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..0f1c270 --- /dev/null +++ b/flake.nix @@ -0,0 +1,28 @@ +{ + description = "Astarte command line client utility"; + + inputs = { + nixpkgs.url = "nixpkgs/nixpkgs-unstable"; + go-utils = { url = "github:noaccOS/go-utils"; inputs.nixpkgs.follows = "nixpkgs"; }; + flake-utils.url = "github:numtide/flake-utils"; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + }; + + outputs = { self, nixpkgs, flake-utils, go-utils, ... }: + flake-utils.lib.eachSystem go-utils.lib.defaultSystems (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlays.${system}.default ]; + }; + in + { + overlays.default = go-utils.lib.asdfOverlay { src = ./.; }; + overlay = self.overlays.default; + devShells.default = pkgs.simpleGoShell; + } + ); +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..4c0de73 --- /dev/null +++ b/shell.nix @@ -0,0 +1,10 @@ +(import + ( + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in + builtins.fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { src = ./.; } +).shellNix