Skip to content

Commit

Permalink
Rewrite CLI in Python
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar committed Jul 22, 2023
1 parent df118d1 commit acb5e15
Show file tree
Hide file tree
Showing 16 changed files with 876 additions and 682 deletions.
2 changes: 1 addition & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"customizations": {
"vscode": {
"extensions": [
"bbenoist.Nix"
"jnoortheen.nix-ide"
]
}
},
Expand Down
4 changes: 0 additions & 4 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
# Used by https://direnv.net
set -euo pipefail

# Use our own last built devenv/nix in CLI
devenv_bin=$(nix build --print-out-paths --accept-flake-config)
PATH_add "$devenv_bin/bin"

# External users should use `source_url` to load this file
source_env ./direnvrc

Expand Down
15 changes: 8 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Nix & devenv
result
.env*
/.env*
.devenv*
/.cache
/.pre-commit-config.yaml
/bin
/include
/lib
pyvenv.cfg
/.direnv
/.venv

# examples
examples/rust/app/target

# Python
/.venv
*.pyc
11 changes: 8 additions & 3 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
{ inputs, pkgs, lib, config, ... }:

{
env = {
# see src/devenv/__init__.py
DEVENV_NIX = inputs.nix.packages.${pkgs.stdenv.system}.nix;
DEVENV_DEVELOP = 1;
};

packages = [
(import ./src/devenv.nix { inherit pkgs; nix = inputs.nix; })
pkgs.cairo
pkgs.xorg.libxcb
pkgs.yaml2json
];

languages.nix.enable = true;
languages.python.enable = true;
languages.python.venv.enable = true;
languages.python.poetry.enable = true;
languages.python.poetry.install.installRootPackage = true;
languages.python.poetry.install.groups = [ "docs" ];

devcontainer.enable = true;
devcontainer.settings.customizations.vscode.extensions = [ "jnoortheen.nix-ide" ];
Expand All @@ -21,7 +27,6 @@

# bin/mkdocs serve --config-file mkdocs.insiders.yml
processes.docs.exec = "mkdocs serve";
processes.build.exec = "${pkgs.watchexec}/bin/watchexec -e nix nix build";

scripts.devenv-bump-version.exec = ''
# TODO: ask for the new version
Expand Down
91 changes: 84 additions & 7 deletions flake.lock

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

8 changes: 5 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@
url = "github:domenkozar/nix/relaxed-flakes";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};

outputs = { self, nixpkgs, pre-commit-hooks, nix, ... }@inputs:
let
systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = f: builtins.listToAttrs (map (name: { inherit name; value = f name; }) systems);
mkPackage = pkgs: import ./src/devenv.nix {
inherit pkgs nix;
};
mkPackage = pkgs: import ./package.nix { inherit pkgs inputs; };
mkDevShellPackage = config: pkgs: import ./src/devenv-devShell.nix { inherit config pkgs; };
mkDocOptions = pkgs:
let
Expand Down
12 changes: 12 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ pkgs, inputs }:

let
python = pkgs.python3Minimal.override { openssl = true; self = python; };
in
(inputs.poetry2nix.legacyPackages.${pkgs.stdenv.system}.mkPoetryApplication {
projectDir = ./.;
inherit python;
}).overrideAttrs (old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ])
++ [ inputs.nix.packages.${pkgs.stdenv.system}.nix ];
})
Loading

0 comments on commit acb5e15

Please sign in to comment.