From 83dbdcea3e3e4c776e7aeda16845656127fe4fe5 Mon Sep 17 00:00:00 2001 From: Paul Brinkmeier Date: Tue, 20 Sep 2022 23:19:18 +0200 Subject: [PATCH] Replace requirements.txt with a Nix flake --- ansible/README.md | 5 +++-- ansible/requirements.txt | 2 -- flake.lock | 42 ++++++++++++++++++++++++++++++++++++++++ flake.nix | 27 ++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 4 deletions(-) delete mode 100644 ansible/requirements.txt create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/ansible/README.md b/ansible/README.md index 0c76780..f94a2f6 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -2,10 +2,11 @@ ## Ansible Control Node Setup -In a Python 3 environment (perhaps a venv), run: +The root of this repo contains a `flake.nix` that defines a shell with all necessary tools. +To drop into a shell with `ansible-*` commands, run: ``` -pip install -r requirements.txt +nix develop ``` ## `misc.yaml` diff --git a/ansible/requirements.txt b/ansible/requirements.txt deleted file mode 100644 index b1dd5dc..0000000 --- a/ansible/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -ansible==6.4.0 -ansible-lint==6.5.2 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..66057a5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1663707275, + "narHash": "sha256-xRIlf8OWJLPxeF5y8iToWx9M1P3pUhPuyXeXUrIjaf8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2f8b8bc98da3cbcf287df9cb4fae4857282fe60a", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..99509b5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,27 @@ +{ + description = "infrastructure environment"; + + inputs = { + # lib + nixpkgs.url = github:nixos/nixpkgs; + flake-utils.url = github:numtide/flake-utils; + }; + + outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + devShells.default = pkgs.mkShell { + buildInputs = [ + pkgs.python3Packages.ansible + pkgs.python3Packages.ansible-lint + ]; + + shellHook = '' + PS1="(infra) $PS1" + ''; + }; + } + ); +}