Skip to content

Commit

Permalink
Fix build issue
Browse files Browse the repository at this point in the history
Applying vlaci#152
  • Loading branch information
enadeau committed Jun 20, 2024
1 parent 17de7eb commit 4cc35c2
Show file tree
Hide file tree
Showing 9 changed files with 574 additions and 452 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,9 @@ venv.bak/

# pre-commit
.pre-commit-cache

# direnv
/.direnv

# Nix
result
104 changes: 98 additions & 6 deletions flake.lock

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

50 changes: 44 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,57 @@
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
flake-utils.url = github:numtide/flake-utils;

poetry2nix = {
url = github:nix-community/poetry2nix;
inputs.flake-utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nix-github-actions.follows = "nix-github-actions";
inputs.treefmt-nix.follows = "treefmt-nix";
inputs.systems.follows = "systems";
};


# Unused but allows downstream to override versions and avoids duplicates

nix-github-actions = {
url = github:nix-community/nix-github-actions;
inputs.nixpkgs.follows = "nixpkgs";
};

systems.url = github:nix-systems/default;

treefmt-nix = {
url = github:numtide/treefmt-nix;
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, flake-utils, nixpkgs }: (flake-utils.lib.eachDefaultSystem (
outputs = { self, nixpkgs, ... }@inputs: (inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
openconnect-sso = (import ./nix { inherit pkgs; }).openconnect-sso;
poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; };

openconnect-pkgs = import ./nix {
inherit pkgs poetry2nix;
sources = null; # make sure we don't mix flakes and Niv
};
in
{
packages = { inherit openconnect-sso; };
defaultPackage = openconnect-sso;
packages = rec {
inherit (openconnect-pkgs) openconnect-sso;

default = openconnect-sso;
};

devShells.default = openconnect-pkgs.shell;
}
) // {
overlay = import ./overlay.nix;
overlays = rec {
default = openconnect-sso;

openconnect-sso = import ./overlay.nix;
};
});
}
26 changes: 10 additions & 16 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
{ sources ? import ./sources.nix
, pkgs ? import <nixpkgs> {
overlays = [ (import "${sources.poetry2nix}/overlay.nix") ];
}
, pkgs ? import <nixpkgs> { }
, poetry2nix ? import sources.poetry2nix { inherit pkgs; }
}:

let
qtLibsFor = with pkgs.lib; dep:
let
qtbase = head (filter (d: getName d.name == "qtbase") dep.nativeBuildInputs);
version = splitVersion qtbase.version;
majorMinor = concatStrings (take 2 version);
in
pkgs."libsForQt${majorMinor}";
inherit (pkgs) python3Packages qt6Packages;

inherit (qtLibsFor pkgs.python3Packages.pyqt5) callPackage;
pythonPackages = pkgs.python3Packages;

openconnect-sso = callPackage ./openconnect-sso.nix { inherit (pkgs) python3Packages; };
openconnect-sso = qt6Packages.callPackage ./openconnect-sso.nix { inherit poetry2nix; };

shell = pkgs.mkShell {
buildInputs = with pkgs; [
Expand All @@ -29,7 +19,7 @@ let
nixpkgs-fmt # To format Nix source files
poetry # Dependency manager for Python
] ++ (
with pythonPackages; [
with python3Packages; [
pre-commit # To check coding style during commit
]
) ++ (
Expand Down Expand Up @@ -59,7 +49,11 @@ let
"\${qtWrapperArgs[@]}"
];
unpackPhase = ":";
nativeBuildInputs = [ pkgs.qt5.wrapQtAppsHook ];

nativeBuildInputs = [
qt6Packages.wrapQtAppsHook
];

installPhase = ''
mkdir -p $out/bin
cat > $out/bin/wrap-qt <<'EOF'
Expand Down
55 changes: 44 additions & 11 deletions nix/openconnect-sso.nix
Original file line number Diff line number Diff line change
@@ -1,32 +1,65 @@
{ lib
, stdenv
, openconnect
, python3
, python3Packages
, poetry2nix
, substituteAll
, qt6Packages
, wrapQtAppsHook
}:

# Nixpkgs' qutebrowser derivation is a good reference to check if something breaks

poetry2nix.mkPoetryApplication {
src = lib.cleanSource ../.;
pyproject = ../pyproject.toml;
poetrylock = ../poetry.lock;
projectDir = ../.;
python = python3;
buildInputs = [ wrapQtAppsHook ];
propagatedBuildInputs = [ openconnect ];

dontWrapQtApps = true;
makeWrapperArgs = [
"\${qtWrapperArgs[@]}"
# Skip dev-dependencies (doesn't seem to work, but doesn't hurt)
groups = [ ];
checkGroups = [ ];

buildInputs = [
python3Packages.setuptools
];

nativeBuildInputs = [
wrapQtAppsHook
];

preferWheels = true;
propagatedBuildInputs = [
openconnect
] ++ lib.optional (stdenv.isLinux) qt6Packages.qtwayland;

dontWrapQtApps = true;
preFixup = ''
makeWrapperArgs+=(
# Force the app to use QT_PLUGIN_PATH values from wrapper
--unset QT_PLUGIN_PATH
"''${qtWrapperArgs[@]}"
# avoid persistant warning on starup
--set QT_STYLE_OVERRIDE Fusion
)
'';

# preferWheels = true;

overrides = [
poetry2nix.defaultPoetryOverrides
(
self: super: {
inherit (python3Packages) cryptography pyqt6 pyqt6-sip pyqt6-webengine six more-itertools;
inherit (python3Packages)
cryptography
more-itertools
pyqt6
pyqt6-sip
pyqt6-webengine
pysocks
requests
six;

coverage-enable-subprocess = super.coverage-enable-subprocess.overridePythonAttrs (old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.setuptools ];
});
}
)
];
Expand Down
14 changes: 7 additions & 7 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
"homepage": "https://github.com/nmattia/niv",
"owner": "nmattia",
"repo": "niv",
"rev": "351d8bc316bf901a81885bab5f52687ec8ccab6e",
"sha256": "1yzhz7ihkh6p2sxhp3amqfbmm2yqzaadqqii1xijymvl8alw5rrr",
"rev": "7b76374b2b44152bfbf41fcb60162c2ce9182e7a",
"sha256": "1ql11hzgxdahj9x0b20b70izcmayb22rinrg82kgp5z19bvpsgrp",
"type": "tarball",
"url": "https://github.com/nmattia/niv/archive/351d8bc316bf901a81885bab5f52687ec8ccab6e.tar.gz",
"url": "https://github.com/nmattia/niv/archive/7b76374b2b44152bfbf41fcb60162c2ce9182e7a.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"poetry2nix": {
"branch": "1.41.0",
"branch": "master",
"description": "Convert poetry projects to nix automagically [maintainer=@adisbladis] ",
"homepage": "",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "585f19cce38a7f75d5bc567b17060ec45bc63ed0",
"sha256": "0dj2a1wzcyilrc9fmfffx6d3bgq7zpawjadd7rphkkq8imh18y6a",
"rev": "0b2bff39e9bd4e6db3208e09c276ca83a063b370",
"sha256": "0qs6y567yqirhys5a9mz1zqppig33pr70kcka4j10vn62p9qi0z4",
"type": "tarball",
"url": "https://github.com/nix-community/poetry2nix/archive/585f19cce38a7f75d5bc567b17060ec45bc63ed0.tar.gz",
"url": "https://github.com/nix-community/poetry2nix/archive/0b2bff39e9bd4e6db3208e09c276ca83a063b370.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
2 changes: 1 addition & 1 deletion overlay.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
final: prev: {
inherit (prev.callPackage ./nix { pkgs = final; }) openconnect-sso;
inherit (import ./nix { pkgs = prev; }) openconnect-sso;
}
Loading

0 comments on commit 4cc35c2

Please sign in to comment.