nix: init flake
Anirudh Oppiliappan x@icyphox.sh
Tue, 18 Jun 2024 00:15:41 +0300
2 files changed,
86 insertions(+),
0 deletions(-)
A
flake.lock
@@ -0,0 +1,26 @@
+{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1718648605, + "narHash": "sha256-NHbsdEMCZ2Ik3/QfKnwGzltkJfAppT8fkzbiUL0Y8wM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "10d4504d04460e05b43e82e86e6e8a8f23b9fe03", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +}
A
flake.nix
@@ -0,0 +1,60 @@
+{ + description = "web frontend for git"; + + inputs.nixpkgs.url = "github:nixos/nixpkgs"; + + outputs = + { self + , nixpkgs + , + }: + let + supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + in + { + packages = forAllSystems (system: + let + pkgs = nixpkgsFor.${system}; + fsrv = self.packages.${system}.fsrv; + files = pkgs.lib.fileset.toSource { + root = ./.; + fileset = pkgs.lib.fileset.unions [ + ./index.html + ]; + }; + in + { + fsrv = pkgs.buildGoModule { + name = "fsrv"; + rev = "master"; + src = ./.; + + vendorHash = "sha256-h0ne2h7Na4aCqqyX3GtQYaG9KKMzKQAjoLccfXtl8Tc="; + }; + docker = pkgs.dockerTools.buildLayeredImage { + name = "sini:5000/fsrv"; + tag = "latest"; + contents = [ files ]; + config = { + Cmd = "${fsrv}/bin/fsrv"; + ExposedPorts = { "9393/tcp" = { }; }; + }; + }; + }); + + defaultPackage = forAllSystems (system: self.packages.${system}.fsrv); + devShells = forAllSystems (system: + let + pkgs = nixpkgsFor.${system}; + in + { + default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + go + ]; + }; + }); + }; +}