Add flake.nix

This also fixes the develop shell to properly include dependencies so python scripts and nixos-shell are available
This commit is contained in:
Tim Van Baak 2023-06-04 18:09:12 -07:00
parent 2d86ccf251
commit 7987a23f07
4 changed files with 101 additions and 24 deletions

View File

@ -1,12 +1,10 @@
{ pkgs ? import <nixpkgs> {}, (import
extraDeps ? [] (
}: let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
let url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
pypkgs = pkgs.python38Packages; sha256 = lock.nodes.flake-compat.locked.narHash;
in pypkgs.buildPythonPackage {
name = "intake";
src = builtins.path { path = ./.; name = "intake"; };
format = "pyproject";
propagatedBuildInputs = with pypkgs; [ flask setuptools ] ++ extraDeps;
} }
)
{ src = ./.; }
).defaultNix

44
flake.lock Normal file
View File

@ -0,0 +1,44 @@
{
"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"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1669833724,
"narHash": "sha256-/HEZNyGbnQecrgJnfE8d0WC5c1xuPSD2LUpB6YXlg4c=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4d2b37a84fad1091b9de401eb450aae66f1a741e",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "22.11",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

37
flake.nix Normal file
View File

@ -0,0 +1,37 @@
{
description = "A personal feed aggregator";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/22.11";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { self, nixpkgs, flake-compat }:
let system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
packages.${system} = {
default = self.packages.${system}.intake;
intake = pkgs.python38Packages.buildPythonPackage {
name = "intake";
src = builtins.path { path = ./.; name = "intake"; };
format = "pyproject";
propagatedBuildInputs = with pkgs.python38Packages; [ flask setuptools ];
};
};
devShells.${system} = {
default = let
pythonEnv = pkgs.python38.withPackages (pypkgs: with pypkgs; [ flask black pytest ]);
in pkgs.mkShell {
packages = [ pythonEnv pkgs.nixos-shell ];
shellHook = ''
PS1="(develop) $PS1"
'';
};
};
};
}

View File

@ -1,12 +1,10 @@
{ pkgs ? import <nixpkgs> {} }: (import
(
let let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
extraDeps = [ fetchTarball {
pkgs.nixos-shell url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
pkgs.python38Packages.black sha256 = lock.nodes.flake-compat.locked.narHash;
pkgs.python38Packages.pytest }
]; )
intake = import ./default.nix { { src = ./.; }
inherit pkgs extraDeps; ).shellNix
};
in intake