feat: initial commit
commit
7183e36b26
|
@ -0,0 +1,8 @@
|
|||
# Created by https://www.toptal.com/developers/gitignore/api/direnv
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=direnv
|
||||
|
||||
### direnv ###
|
||||
.direnv
|
||||
.envrc
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/direnv
|
|
@ -0,0 +1,5 @@
|
|||
{ pkgs ? import <nixpkgs> { } }:
|
||||
let
|
||||
lib = import ../lib.nix { inherit pkgs; };
|
||||
in
|
||||
lib.genNetrc { projectDir = ./.; }
|
|
@ -0,0 +1,7 @@
|
|||
# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand.
|
||||
package = []
|
||||
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.11"
|
||||
content-hash = "8ebb161448cb827b31357cc68b7c8ada8dd31f9185cc957d9ccedf69ecb28673"
|
|
@ -0,0 +1,7 @@
|
|||
[http-basic.foo]
|
||||
username = "foo"
|
||||
password = "bar"
|
||||
|
||||
[http-basic.foo2]
|
||||
username = "foo2"
|
||||
password = "bar2"
|
|
@ -0,0 +1,27 @@
|
|||
[tool.poetry]
|
||||
name = "example"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.11"
|
||||
|
||||
[[tool.poetry.source]]
|
||||
name = "foo"
|
||||
url = "https://foo.bar/simple/"
|
||||
priority = "primary"
|
||||
|
||||
[[tool.poetry.source]]
|
||||
name = "foo2"
|
||||
url = "https://foo2.bar/simple/"
|
||||
priority = "primary"
|
||||
|
||||
[[tool.poetry.source]]
|
||||
name = "PyPI"
|
||||
priority = "primary"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1704982712,
|
||||
"narHash": "sha256-2Ptt+9h8dczgle2Oo6z5ni5rt/uLMG47UFTR1ry/wgg=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "07f6395285469419cf9d078f59b5b49993198c00",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "flake-parts",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1705133751,
|
||||
"narHash": "sha256-rCIsyE80jgiOU78gCWN3A0wE0tR2GI5nH6MlS+HaaSQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9b19f5e77dd906cb52dade0b7bd280339d2a1f3d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"dir": "lib",
|
||||
"lastModified": 1703961334,
|
||||
"narHash": "sha256-M1mV/Cq+pgjk0rt6VxoyyD+O8cOUiai8t9Q6Yyq4noY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b0d36bd0a420ecee3bc916c91886caca87c894e9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"dir": "lib",
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
description = "Description for the project";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = inputs@{ flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
imports = [
|
||||
# To import a flake module
|
||||
# 1. Add foo to inputs
|
||||
# 2. Add foo as a parameter to the outputs function
|
||||
# 3. Add here: foo.flakeModule
|
||||
|
||||
];
|
||||
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
|
||||
perSystem = { config, self', inputs', pkgs, system, ... }: {
|
||||
# Per-system attributes can be defined here. The self' and inputs'
|
||||
# module parameters provide easy access to attributes of the same
|
||||
# system.
|
||||
|
||||
# Equivalent to inputs'.nixpkgs.legacyPackages.hello;
|
||||
packages.default = pkgs.hello;
|
||||
};
|
||||
flake = {
|
||||
# The usual flake attributes can be defined here, including system-
|
||||
# agnostic ones like nixosModule and system-enumerating ones, although
|
||||
# those are more easily expressed in perSystem.
|
||||
|
||||
};
|
||||
};
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
{ pkgs ? import <nixpkgs> { }
|
||||
, lib ? pkgs.lib
|
||||
}:
|
||||
{
|
||||
genNetrc =
|
||||
{ projectDir ? null
|
||||
, poetry ? projectDir + "/poetry.toml"
|
||||
, pyproject ? projectDir + "/pyproject.toml"
|
||||
}:
|
||||
let
|
||||
poetryToml = builtins.fromTOML (builtins.readFile poetry);
|
||||
pyprojectToml = builtins.fromTOML (builtins.readFile pyproject);
|
||||
|
||||
sourceNames = builtins.attrNames poetryToml.http-basic;
|
||||
authSources =
|
||||
let
|
||||
sourceNeedsAuth = { name, ... }: builtins.elem name sourceNames;
|
||||
in
|
||||
builtins.filter sourceNeedsAuth pyprojectToml.tool.poetry.source;
|
||||
mergedSources = map (source: source // (builtins.getAttr source.name poetryToml.http-basic)) authSources;
|
||||
|
||||
mkMachine = url:
|
||||
let
|
||||
matches = builtins.split "(https?://)([^/]*)(.*)" url;
|
||||
mainMatch = builtins.elemAt matches 1;
|
||||
domain = builtins.elemAt mainMatch 1;
|
||||
in
|
||||
domain;
|
||||
mkEntry = { url, username, password, ... }:
|
||||
"machine ${mkMachine url} login ${username} password ${password}";
|
||||
entries = map mkEntry mergedSources;
|
||||
contents = lib.concatLines entries;
|
||||
in
|
||||
pkgs.writeText "netrc" contents;
|
||||
}
|
Loading…
Reference in New Issue