Add nix flake files

This commit is contained in:
George Shammas 2020-11-15 21:05:14 -05:00
parent 63fa2caee0
commit 0f6591ff04
5 changed files with 125 additions and 0 deletions

1
.version Normal file
View File

@ -0,0 +1 @@
0.0.1

9
default.nix Normal file
View File

@ -0,0 +1,9 @@
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in 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 = ./.;
}).defaultNix

39
flake.lock Normal file
View File

@ -0,0 +1,39 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1603796912,
"narHash": "sha256-6ayqpH/4XiEXylNdWI3AghubqS6XuiPg3Y60jY8RTo4=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "19576c2aea7f074ff0da818b21a8b0950ff6ec86",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"narHash": "sha256-gnopQLNQVt3pWBUT9gsPWmfDaYmQF4H5+k6QJmpuZdI=",
"path": "/nix/store/ipbl0zskimmqm7zm7qrh4nbrfk3jgmvi-source",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

67
flake.nix Normal file
View File

@ -0,0 +1,67 @@
{
inputs = {
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { self, nixpkgs, ... }:
let
version = builtins.replaceStrings [ "\n" ] [ "" ]
(builtins.readFile ./.version + versionSuffix);
versionSuffix = if officialRelease then
""
else
"pre${
nixpkgs.lib.substring 0 8 (self.lastModifiedDate or self.lastModified)
}_${self.shortRev or "dirty"}";
officialRelease = false;
systems = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
# Memoize nixpkgs for different platforms for efficiency.
nixpkgsFor = forAllSystems (system:
import nixpkgs {
inherit system;
overlays = [ self.overlay ];
});
in {
overlay = final: prev: {
ifconfigio = with final;
with pkgs;
(buildGoModule {
name = "ifconfig.io-${version}";
src = self;
vendorSha256 =
"sha256-Xyf/K7pu87cRNGMpVQoVqiJ6s+Xpw0N7NDg7vqLFErk=";
postInstall = ''
mkdir -p $out/usr/lib/ifconfig.io/
cp -r ./templates $out/usr/lib/ifconfig.io
'';
});
};
packages =
forAllSystems (system: { inherit (nixpkgsFor.${system}) ifconfigio; });
defaultPackage =
forAllSystems (system: self.packages.${system}.ifconfigio);
nixosModules.ifconfigio = { pkgs, ... }: {
nixpkgs.overlays = [ self.overlay ];
systemd.packages = [ pkgs.ifconfigio ];
users.users.ifconfigio = {
description = "ifconfig.io daemon user";
group = "ifconfigio";
isSystemUser = true;
};
users.groups.ifconfigio = { };
};
};
}

9
shell.nix Normal file
View File

@ -0,0 +1,9 @@
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in 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