Skip to content

Commit

Permalink
initial default package
Browse files Browse the repository at this point in the history
  • Loading branch information
Mast3rwaf1z committed Jun 7, 2024
1 parent 3547617 commit e7c9a00
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
outputs = { self, nixpkgs }: let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };

# Custom package as django-select2 is not in nixpkgs
django-select2 = pkgVersion: pkgs.python311Packages.buildPythonPackage rec {
pname = "django_select2";
Expand All @@ -29,7 +30,7 @@
lines = pkgs.lib.lists.remove "" (pkgs.lib.strings.splitString "\n" (builtins.readFile requirements));

# Map a function to convert the list of strings into a list of derivations
dependencies = builtins.map
dependencies = ver: builtins.map
(package: let
# pkgList is a function defined here via currying, it will just return the item at index in the list generated after splitting by ==
pkgList = builtins.elemAt (pkgs.lib.strings.splitString "==" package);
Expand All @@ -40,14 +41,37 @@
django-select2 pkgVersion
else
# Add the standard derivation of the package, attempt to set the version
pkgs.python311Packages."${pkgName}".overrideAttrs { version = pkgVersion; }
ver."${pkgName}".overrideAttrs { version = pkgVersion; }
)
lines;

in {
# Define the shell, here we're just setting the packages required for the devshell
devShells.x86_64-linux.default = pkgs.mkShell {
packages = dependencies ++ [pkgs.mailhog pkgs.black];
devShells.${system}.default = pkgs.mkShell {
packages = (dependencies pkgs.python3Packages) ++ [pkgs.mailhog pkgs.black];
};

# Default package for the stregsystem
packages.${system}.default = let
env = pkgs.python3.withPackages (_: []);
in pkgs.stdenv.mkDerivation {
pname = "Stregsystemet";
version = "latest";
src = ./.;

installPhase = ''
mkdir -p $out/bin
mkdir -p $out/share/stregsystemet
cp local.cfg.skel local.cfg
echo "${env.interpreter} $out/share/stregsystemet/manage.py \$@" > $out/bin/stregsystemet
sed -i '1 i #!${pkgs.bash}/bin/bash' $out/bin/stregsystemet
chmod +x $out/bin/stregsystemet
sed -i '1d' manage.py
cp ./* $out/share/stregsystemet -r
'';
};
};
}

0 comments on commit e7c9a00

Please sign in to comment.