-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from simojo/main
chore: ruff linting; devenv setup
- Loading branch information
Showing
11 changed files
with
349 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
inputs = { | ||
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; | ||
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs"; | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
devenv.url = "github:cachix/devenv?dir=src/modules"; | ||
} // (if builtins.pathExists ./.devenv/flake.json | ||
then builtins.fromJSON (builtins.readFile ./.devenv/flake.json) | ||
else {}); | ||
|
||
outputs = { nixpkgs, ... }@inputs: | ||
let | ||
devenv = if builtins.pathExists ./.devenv/devenv.json | ||
then builtins.fromJSON (builtins.readFile ./.devenv/devenv.json) | ||
else {}; | ||
getOverlays = inputName: inputAttrs: | ||
map (overlay: let | ||
input = inputs.${inputName} or (throw "No such input `${inputName}` while trying to configure overlays."); | ||
in input.overlays.${overlay} or (throw "Input `${inputName}` has no overlay called `${overlay}`. Supported overlays: ${nixpkgs.lib.concatStringsSep ", " (builtins.attrNames input.overlays)}")) | ||
inputAttrs.overlays or []; | ||
overlays = nixpkgs.lib.flatten (nixpkgs.lib.mapAttrsToList getOverlays (devenv.inputs or {})); | ||
pkgs = import nixpkgs { | ||
system = "x86_64-linux"; | ||
config = { | ||
allowUnfree = devenv.allowUnfree or false; | ||
permittedInsecurePackages = devenv.permittedInsecurePackages or []; | ||
}; | ||
inherit overlays; | ||
}; | ||
lib = pkgs.lib; | ||
importModule = path: | ||
if lib.hasPrefix "./" path | ||
then ./. + (builtins.substring 1 255 path) + "/devenv.nix" | ||
else if lib.hasPrefix "../" path | ||
then throw "devenv: ../ is not supported for imports" | ||
else let | ||
paths = lib.splitString "/" path; | ||
name = builtins.head paths; | ||
input = inputs.${name} or (throw "Unknown input ${name}"); | ||
subpath = "/${lib.concatStringsSep "/" (builtins.tail paths)}"; | ||
devenvpath = "${input}" + subpath + "/devenv.nix"; | ||
in if builtins.pathExists devenvpath | ||
then devenvpath | ||
else throw (devenvpath + " file does not exist for input ${name}."); | ||
project = pkgs.lib.evalModules { | ||
specialArgs = inputs // { inherit inputs pkgs; }; | ||
modules = [ | ||
(inputs.devenv.modules + /top-level.nix) | ||
{ devenv.cliVersion = "0.6.3"; } | ||
] ++ (map importModule (devenv.imports or [])) ++ [ | ||
./devenv.nix | ||
(devenv.devenv or {}) | ||
(if builtins.pathExists ./devenv.local.nix then ./devenv.local.nix else {}) | ||
]; | ||
}; | ||
config = project.config; | ||
|
||
options = pkgs.nixosOptionsDoc { | ||
options = builtins.removeAttrs project.options [ "_module" ]; | ||
# Unpack Nix types, e.g. literalExpression, mDoc. | ||
transformOptions = | ||
let isDocType = v: builtins.elem v [ "literalDocBook" "literalExpression" "literalMD" "mdDoc" ]; | ||
in lib.attrsets.mapAttrs (_: v: | ||
if v ? _type && isDocType v._type then | ||
v.text | ||
else if v ? _type && v._type == "derivation" then | ||
v.name | ||
else | ||
v | ||
); | ||
}; | ||
in { | ||
packages."x86_64-linux" = { | ||
optionsJSON = options.optionsJSON; | ||
inherit (config) info procfileScript procfileEnv procfile; | ||
ci = config.ciDerivation; | ||
}; | ||
devenv.containers = config.containers; | ||
devShell."x86_64-linux" = config.shell; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"inputs": {"nixpkgs": {"url": "github:NixOS/nixpkgs/nixpkgs-unstable"}, "nixpkgs-python": {"url": "github:cachix/nixpkgs-python"}}, "allowUnfree": false} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"nixpkgs": {"url": "github:NixOS/nixpkgs/nixpkgs-unstable"}, "nixpkgs-python": {"url": "github:cachix/nixpkgs-python"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
shell-1-link |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/nix/store/p4y6p2djvxxmck22kpzjymszjqwxp63s-devenv-shell-env |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/nix/store/ym47k4l1n6y5dq75lysimdc3s5qzw3x5-devenv-profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,241 @@ | ||
{ | ||
"nodes": { | ||
"devenv": { | ||
"locked": { | ||
"dir": "src/modules", | ||
"lastModified": 1704835383, | ||
"narHash": "sha256-SoC0rYR9iHW0dVOEmxNEfa8vk9dTK86P5iXTgHafmwM=", | ||
"owner": "cachix", | ||
"repo": "devenv", | ||
"rev": "18ef9849d1ecac7a9a7920eb4f2e4adcf67a8c3a", | ||
"type": "github" | ||
}, | ||
"original": { | ||
"dir": "src/modules", | ||
"owner": "cachix", | ||
"repo": "devenv", | ||
"type": "github" | ||
} | ||
}, | ||
"flake-compat": { | ||
"flake": false, | ||
"locked": { | ||
"lastModified": 1696426674, | ||
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", | ||
"owner": "edolstra", | ||
"repo": "flake-compat", | ||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", | ||
"type": "github" | ||
}, | ||
"original": { | ||
"owner": "edolstra", | ||
"repo": "flake-compat", | ||
"type": "github" | ||
} | ||
}, | ||
"flake-compat_2": { | ||
"flake": false, | ||
"locked": { | ||
"lastModified": 1673956053, | ||
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", | ||
"owner": "edolstra", | ||
"repo": "flake-compat", | ||
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", | ||
"type": "github" | ||
}, | ||
"original": { | ||
"owner": "edolstra", | ||
"repo": "flake-compat", | ||
"type": "github" | ||
} | ||
}, | ||
"flake-utils": { | ||
"inputs": { | ||
"systems": "systems" | ||
}, | ||
"locked": { | ||
"lastModified": 1701680307, | ||
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", | ||
"owner": "numtide", | ||
"repo": "flake-utils", | ||
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725", | ||
"type": "github" | ||
}, | ||
"original": { | ||
"id": "flake-utils", | ||
"type": "indirect" | ||
} | ||
}, | ||
"flake-utils_2": { | ||
"inputs": { | ||
"systems": "systems_2" | ||
}, | ||
"locked": { | ||
"lastModified": 1685518550, | ||
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", | ||
"owner": "numtide", | ||
"repo": "flake-utils", | ||
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", | ||
"type": "github" | ||
}, | ||
"original": { | ||
"owner": "numtide", | ||
"repo": "flake-utils", | ||
"type": "github" | ||
} | ||
}, | ||
"gitignore": { | ||
"inputs": { | ||
"nixpkgs": [ | ||
"pre-commit-hooks", | ||
"nixpkgs" | ||
] | ||
}, | ||
"locked": { | ||
"lastModified": 1660459072, | ||
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", | ||
"owner": "hercules-ci", | ||
"repo": "gitignore.nix", | ||
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", | ||
"type": "github" | ||
}, | ||
"original": { | ||
"owner": "hercules-ci", | ||
"repo": "gitignore.nix", | ||
"type": "github" | ||
} | ||
}, | ||
"nixpkgs": { | ||
"locked": { | ||
"lastModified": 1704842529, | ||
"narHash": "sha256-OTeQA+F8d/Evad33JMfuXC89VMetQbsU4qcaePchGr4=", | ||
"owner": "NixOS", | ||
"repo": "nixpkgs", | ||
"rev": "eabe8d3eface69f5bb16c18f8662a702f50c20d5", | ||
"type": "github" | ||
}, | ||
"original": { | ||
"owner": "NixOS", | ||
"ref": "nixpkgs-unstable", | ||
"repo": "nixpkgs", | ||
"type": "github" | ||
} | ||
}, | ||
"nixpkgs-python": { | ||
"inputs": { | ||
"flake-compat": "flake-compat", | ||
"flake-utils": "flake-utils", | ||
"nixpkgs": "nixpkgs_2" | ||
}, | ||
"locked": { | ||
"lastModified": 1704974031, | ||
"narHash": "sha256-NTfe4u2fEfVBFapHaN4k+wsTs994z7WibVb76S/sJDU=", | ||
"owner": "cachix", | ||
"repo": "nixpkgs-python", | ||
"rev": "430014003f0ae26bb2c697f65e66acc096113267", | ||
"type": "github" | ||
}, | ||
"original": { | ||
"owner": "cachix", | ||
"repo": "nixpkgs-python", | ||
"type": "github" | ||
} | ||
}, | ||
"nixpkgs-stable": { | ||
"locked": { | ||
"lastModified": 1685801374, | ||
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", | ||
"owner": "NixOS", | ||
"repo": "nixpkgs", | ||
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373", | ||
"type": "github" | ||
}, | ||
"original": { | ||
"owner": "NixOS", | ||
"ref": "nixos-23.05", | ||
"repo": "nixpkgs", | ||
"type": "github" | ||
} | ||
}, | ||
"nixpkgs_2": { | ||
"locked": { | ||
"lastModified": 1704874635, | ||
"narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=", | ||
"owner": "NixOS", | ||
"repo": "nixpkgs", | ||
"rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356", | ||
"type": "github" | ||
}, | ||
"original": { | ||
"owner": "NixOS", | ||
"ref": "nixos-23.11", | ||
"repo": "nixpkgs", | ||
"type": "github" | ||
} | ||
}, | ||
"pre-commit-hooks": { | ||
"inputs": { | ||
"flake-compat": "flake-compat_2", | ||
"flake-utils": "flake-utils_2", | ||
"gitignore": "gitignore", | ||
"nixpkgs": [ | ||
"nixpkgs" | ||
], | ||
"nixpkgs-stable": "nixpkgs-stable" | ||
}, | ||
"locked": { | ||
"lastModified": 1704913983, | ||
"narHash": "sha256-K/GuHFFriQhH3VPWMhm6bYelDuPyGGjGu1OF1EWUn5k=", | ||
"owner": "cachix", | ||
"repo": "pre-commit-hooks.nix", | ||
"rev": "b0265634df1dc584585c159b775120e637afdb41", | ||
"type": "github" | ||
}, | ||
"original": { | ||
"owner": "cachix", | ||
"repo": "pre-commit-hooks.nix", | ||
"type": "github" | ||
} | ||
}, | ||
"root": { | ||
"inputs": { | ||
"devenv": "devenv", | ||
"nixpkgs": "nixpkgs", | ||
"nixpkgs-python": "nixpkgs-python", | ||
"pre-commit-hooks": "pre-commit-hooks" | ||
} | ||
}, | ||
"systems": { | ||
"locked": { | ||
"lastModified": 1681028828, | ||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", | ||
"owner": "nix-systems", | ||
"repo": "default", | ||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", | ||
"type": "github" | ||
}, | ||
"original": { | ||
"owner": "nix-systems", | ||
"repo": "default", | ||
"type": "github" | ||
} | ||
}, | ||
"systems_2": { | ||
"locked": { | ||
"lastModified": 1681028828, | ||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", | ||
"owner": "nix-systems", | ||
"repo": "default", | ||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", | ||
"type": "github" | ||
}, | ||
"original": { | ||
"owner": "nix-systems", | ||
"repo": "default", | ||
"type": "github" | ||
} | ||
} | ||
}, | ||
"root": "root", | ||
"version": 7 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ pkgs, config, ... }: | ||
|
||
{ | ||
packages = [ | ||
pkgs.git | ||
pkgs.zlib | ||
pkgs.gcc | ||
pkgs.cargo | ||
pkgs.gnuplot | ||
]; | ||
languages.python = { | ||
enable = true; | ||
poetry.enable = true; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
inputs: | ||
nixpkgs: | ||
url: github:NixOS/nixpkgs/nixpkgs-unstable | ||
nixpkgs-python: | ||
url: github:cachix/nixpkgs-python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[installer] | ||
no-binary = ["ruff"] |