Skip to content

Commit

Permalink
Update ip_addresses to match new format in sync (#264)
Browse files Browse the repository at this point in the history
* Update ip_addresses to hash format

* Add nix flake support
  • Loading branch information
justinbarclay authored Oct 5, 2023
1 parent 218584f commit 32034db
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions unix/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake . --impure
27 changes: 27 additions & 0 deletions unix/flake.lock

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

46 changes: 46 additions & 0 deletions unix/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
in
{
devShells = forAllSystems (system: {
default = pkgs.${system}.mkShellNoCC {
venvDir = "./.venv";
buildInputs = with pkgs.${system}; [
# A Python interpreter including the 'venv' module is required to bootstrap
# the environment.
python3Packages.python

# This execute some shell code to initialize a venv in $venvDir before
# dropping into the shell
python3Packages.venvShellHook
python3Packages.python-lsp-server
# In this particular example, in order to compile any binary extensions they may
# require, the Python modules listed in the hypothetical requirements.txt need
# the following packages to be installed locally:
python3Packages.wheel
python3Packages.setuptools
libvirt
];

# Run this command, only after creating the virtual environment
postVenvCreation = ''
unset SOURCE_DATE_EPOCH
pip install -r ./requirements.txt
'';

# Now we can execute any commands within the virtual environment.
# This is optional and can be left out to run pip manually.
postShellHook = ''
# allow pip to install wheels
unset SOURCE_DATE_EPOCH
'';
};
});
};
}
4 changes: 4 additions & 0 deletions unix/src/machine_stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ def cpu_name(proc):
return proc[2]
return "Unknown"

def ip_addresses(facts):
"""Return IP addresses formatted for the tidal API"""
return list(map(lambda ip: {"address": ip},
facts["ansible_all_ipv4_addresses"] + facts["ansible_all_ipv6_addresses"]))

class ResultCallback(CallbackBase):
"""A sample callback plugin used for performing an action as results come in
Expand Down

0 comments on commit 32034db

Please sign in to comment.