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 nix environment and update script #171

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use nix
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.pyc
.mypy_cache
.ruff_cache
.direnv
MANIFEST
build
dist
Expand Down
47 changes: 47 additions & 0 deletions npins/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Generated by npins. Do not modify; will be overwritten regularly
let
data = builtins.fromJSON (builtins.readFile ./sources.json);
version = data.version;

mkSource = spec:
assert spec ? type; let
path =
if spec.type == "Git" then mkGitSource spec
else if spec.type == "GitRelease" then mkGitSource spec
else if spec.type == "PyPi" then mkPyPiSource spec
else if spec.type == "Channel" then mkChannelSource spec
else builtins.throw "Unknown source type ${spec.type}";
in
spec // { outPath = path; };

mkGitSource = { repository, revision, url ? null, hash, ... }:
assert repository ? type;
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
# In the latter case, there we will always be an url to the tarball
if url != null then
(builtins.fetchTarball {
inherit url;
sha256 = hash; # FIXME: check nix version & use SRI hashes
})
else assert repository.type == "Git"; builtins.fetchGit {
url = repository.url;
rev = revision;
# hash = hash;
};

mkPyPiSource = { url, hash, ... }:
builtins.fetchurl {
inherit url;
sha256 = hash;
};

mkChannelSource = { url, hash, ... }:
builtins.fetchTarball {
inherit url;
sha256 = hash;
};
in
if version == 3 then
builtins.mapAttrs (_: mkSource) data.pins
else
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"
11 changes: 11 additions & 0 deletions npins/sources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"pins": {
"nixpkgs": {
"type": "Channel",
"name": "nixos-unstable",
"url": "https://releases.nixos.org/nixos/unstable/nixos-24.05pre588267.73de017ef2d1/nixexprs.tar.xz",
"hash": "1hcnwcankhqh0pk7g0njszm3553a6845dzy1yzq3jy5msrr4l2qy"
}
},
"version": 3
}
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ authors = [
{email = "[email protected]"},
{name = "Christoph Reiter"}
]
dependencies = [
# for @deprecated decorator
'typing_extensions>="4.5.0"; python_version<"3.13"',
]
classifiers = [
"Programming Language :: Python :: 3",
"Intended Audience :: Developers",
Expand Down Expand Up @@ -50,7 +54,8 @@ include = '\.pyi?$'
skip = "*__pycache__*,.mypy_cache,.git,test,*.pyi"
ignore-words-list = """
astroid,
inout"""
inout,
gir"""

[tool.isort]
force_alphabetical_sort_within_sections = true
Expand Down
63 changes: 63 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
let
sources = import ./npins;
pkgs = import sources.nixpkgs {};
in
pkgs.mkShell {
nativeBuildInputs = [
pkgs.gobject-introspection
(pkgs.python3.withPackages (pp: [
pp.black
pp.isort
pp.mypy
pp.pygobject3
]))
];

buildInputs = [
pkgs.appstream
pkgs.atk
pkgs.cinnamon.xapp
pkgs.farstream
pkgs.flatpak
pkgs.gdk-pixbuf
pkgs.geoclue2
pkgs.glib
pkgs.gnome-online-accounts
pkgs.gobject-introspection
pkgs.graphene
pkgs.gsound
pkgs.gspell
pkgs.gst_all_1.gst-plugins-bad # GstWebRTC
pkgs.gst_all_1.gst-plugins-base
pkgs.gst_all_1.gstreamer
pkgs.gtk3
pkgs.gtk4
pkgs.gtksourceview4
pkgs.gtksourceview5
pkgs.libgudev # required by manette
pkgs.libadwaita
pkgs.libappindicator-gtk3
pkgs.libayatana-appindicator
pkgs.libgit2-glib
pkgs.libhandy
pkgs.libmanette
pkgs.libnotify
pkgs.libpanel
pkgs.libportal
pkgs.librsvg
pkgs.libsecret
pkgs.libsoup
pkgs.libsoup_3
pkgs.ostree
pkgs.pango
pkgs.vte
pkgs.webkitgtk_6_0
];

env = {
# Ensure the environment is not contaminated.
XDG_DATA_DIRS = "";
GI_GIR_PATH = "";
GI_TYPELIB_PATH = "";
};
}
Loading
Loading