Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a nix flake setup #17

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
description = "Python package for controlling an ElGato key light";

inputs.nixpkgs.url = "github:NixOS/nixpkgs";

outputs = { self, nixpkgs }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;

leglight = pkgs.python38Packages.buildPythonPackage rec {
Copy link

@Pacman99 Pacman99 Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is opinionated and I have seen other flakes not follow this, but I try not to put too much logic like package creation in the flake.nix. I would put the package in a default.nix and this flake can just call that. I consider flakes more of a place where the sharing aspect comes in and including implementation logic hurts other's ability to see whats happening in your flake. flake.nix to me is a summary of your repo: what it needs, what it exports.

pname = "leglight";
version = "0.2.0";

src = pkgs.python38Packages.fetchPypi {
inherit pname version;
sha256 = "41ab462fe12e2ec3e02ff29a00316f822b078c331c70bd36a635568bd1c4204a";
};

propagatedBuildInputs = with pkgs.python38Packages; [
zeroconf
requests
];

doCheck = false;
};
in {
devShell.x86_64-linux = pkgs.mkShell {
buildInputs = with pkgs; [
python38
pipenv
];
};

defaultPackage.x86_64-linux = pkgs.python38Packages.buildPythonPackage rec {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this package only support x86_64-linux? Theres a project called flake-utils you can check out which makes this process easier, so you can go utils.lib.eachDefaultSystem (system: defaultPackage = ...; ) and the outputs get "system spaced".

pname = "PyElgato";
version = "1.2.0";

src = pkgs.python38Packages.fetchPypi {
inherit pname version;
sha256 = "7834d4c6dac7a1646b5238dcec187645d6cd4d8dc4e2f3f9e0d789a3bddd369c";
};

buildInputs = with pkgs.python38Packages; [
setuptools-scm
wheel
];

propagatedBuildInputs = [
leglight
];

doCheck = false;
};
};
}