From 383c126c6a92a80a6fd4a5af686699ef16082b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Sat, 25 Jun 2022 09:14:15 +0100 Subject: [PATCH] convert to flakes --- .envrc | 3 ++- .gitignore | 1 + flake.lock | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ shell.nix | 43 ++++++++++++---------------------------- 5 files changed, 128 insertions(+), 31 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc index 051d09d..e3fecb3 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,2 @@ -eval "$(lorri direnv)" +use flake + diff --git a/.gitignore b/.gitignore index 43dd795..b1d1787 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ public/ resources/_gen/ +.direnv/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d8baebf --- /dev/null +++ b/flake.lock @@ -0,0 +1,58 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1655876541, + "narHash": "sha256-eOz1YNclUTobC2f9meWpw+idhzWImdti43OKjLBoDq8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a0edeb02ae5b92eda6efbee4e26d8c33c15063fd", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1656065134, + "narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b89c8c0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,54 @@ +{ + description = "legdur: verify integrity of large directories over time"; + inputs = { + utils.url = "github:numtide/flake-utils"; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + }; + + outputs = { self, nixpkgs, utils, flake-compat }: + utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages."${system}"; + netlify-deployer = pkgs.python38Packages.buildPythonPackage rec { + pname = "netlify_deployer"; + version = "0.5.2"; + + src = pkgs.python38Packages.fetchPypi { + inherit pname version; + sha256 = + "aae0092b36e7408281ad73269b446c701edaacecc8ba1a07cc85671e3ddfae6e"; + }; + + propagatedBuildInputs = with pkgs; + with pkgs.python38Packages; [ + requests + git + pbr + wheel + setuptools + ]; + + doCheck = false; + }; + + customPython = + pkgs.python38.buildEnv.override { extraLibs = [ netlify-deployer ]; }; + in rec { + # `nix develop` + devShell = pkgs.mkShell { + nativeBuildInputs = with pkgs; + with pkgs.python38Packages; [ + git + hugo + cacert + requests + pip + virtualenv + customPython + ]; + }; + }); +} diff --git a/shell.nix b/shell.nix index c0d922b..e7bdb49 100644 --- a/shell.nix +++ b/shell.nix @@ -1,31 +1,14 @@ -let - pkgs = import {}; - netlify-deployer = pkgs.python38Packages.buildPythonPackage rec { - pname = "netlify_deployer"; - version = "0.5.2"; +(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 - src = pkgs.python38Packages.fetchPypi { - inherit pname version; - sha256 = "aae0092b36e7408281ad73269b446c701edaacecc8ba1a07cc85671e3ddfae6e"; - }; - - propagatedBuildInputs = with pkgs; with pkgs.python38Packages; [ requests git pbr wheel setuptools ]; - - doCheck = false; - }; - - customPython = pkgs.python38.buildEnv.override { - extraLibs = [ netlify-deployer ]; - }; -in -pkgs.mkShell { - buildInputs = with pkgs; with pkgs.python38Packages; [ - git - hugo - cacert - requests - pip - virtualenv - customPython - ]; -}