W2MX3YW4OTK4DNSA4BUULWA3DFWE5E77EFCEPQQFHP7AKZZMZYQAC cmake_minimum_required(VERSION 3.25)project(wttr-delft VERSION 1.0 LANGUAGES C)find_package(CURL REQUIRED)add_executable(wttr-delft simple.c)target_link_libraries(wttr-delft PRIVATE CURL::libcurl)install(TARGETS wttr-delft RUNTIME DESTINATION bin)
{ stdenv, cmake, curl}:stdenv.mkDerivation rec {# Our package namename = "wttr-delft";# Where the source code livessrc = builtins.path { path = ../src; name = name; };# Build-time dependenciesnativeBuildInputs = [cmake];# DependenciesbuildInputs = [curl.dev];}
{ pkgs }:letregistriesConf = pkgs.writeText "registries.conf" ''[registries.search]registries = ['docker.io'][registries.block]registries = []'';storageConf = pkgs.writeText "storage.conf" ''[storage]driver = "overlay"# rootless_storage_path="$XDG_DATA_HOME/containers/storage"'';in pkgs.writeShellScript "podman-setup" ''# Dont overwrite customised configurationif ! test -f ~/.config/containers/policy.json; thenecho "Installing missing ~/.config/containers/policy.json"install -Dm644 ${pkgs.skopeo.src}/default-policy.json ~/.config/containers/policy.jsonfiif ! test -f ~/.config/containers/registries.conf; thenecho "Installing missing ~/.config/containers/registries.conf"install -Dm644 ${registriesConf} ~/.config/containers/registries.conffiif ! test -f ~/.config/containers/storage.conf; thenecho "Installing missing ~/.config/containers/storage.conf"install -Dm644 ${storageConf} ~/.config/containers/storage.conffiif ! grep -q "^''${USER}:" /etc/subuid; thenecho "No subuid range defined for user, consider running 'sudo usermod --add-subuids 10000-75535 ''${USER}' to allow rootless podman to work"fi''
# This is a Nix flake# It is written in the Nix expression language{description = "Simple flake for simple libcurl example";# nixpkgs is the package repository for the Nix package managerinputs = {flake-utils.url = "github:numtide/flake-utils";nixpkgs.url = "github:NixOS/nixpkgs";};outputs = { self, nixpkgs, flake-utils }:flake-utils.lib.eachDefaultSystem (system:let# In this simple example we choose to build for "x86_64-linux" onlypkgs = import nixpkgs {inherit system;overlays = [(final: prev: {wttr-delft = prev.callPackage ./wttr-delft.nix {};})];};# Docker image containing only wttr-delftwttr-delft-container = pkgs.dockerTools.buildLayeredImage {name = "wttr-delft";tag = "nix";# created = "now";contents = [pkgs.wttr-delft];config = {Cmd = ["${pkgs.wttr-delft}/bin/wttr-delft"];# Needed for curl to workEnv = ["SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"];};};# Development shell for interacting with containers# Based on https://gist.github.com/adisbladis/187204cb772800489ee3dac4acdd9947podman-devshell = let# Provides a script that copies/creates files that are required for rootless podmanpodmanSetupScript = import ./podman-setup-script.nix { inherit pkgs; };# Provides a fake "docker" binary mapping to podmandockerCompat = pkgs.runCommandNoCC "docker-podman-compat" {} ''mkdir -p $out/binln -s ${pkgs.podman}/bin/podman $out/bin/docker'';in pkgs.mkShell {name = "podman";buildInputs = with pkgs; [podman # Manage pods, containers and imagesrunc # Container runtimeconmon # Container runtime monitorskopeo # Interact with container registryslirp4netns # User-mode networking for unprivileged namespacesfuse-overlayfs # CoW for images, much faster than default vfsdockerCompat # Aliases for docker / podman];shellHook = ''# Install configuration required for rootless podman${podmanSetupScript}'';};in# These are the flake outputs, i.e. what we can consume{packages = {default = pkgs.wttr-delft;# static = pkgs.pkgsCross.musl64.pkgsStatic.wttr-delft;container = wttr-delft-container;};devShells = {default = pkgs.wttr-delft;podman = podman-devshell;};});}
{"nodes": {"flake-utils": {"locked": {"lastModified": 1678901627,"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=","owner": "numtide","repo": "flake-utils","rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6","type": "github"},"original": {"owner": "numtide","repo": "flake-utils","type": "github"}},"nixpkgs": {"locked": {"lastModified": 1679396235,"narHash": "sha256-RjmNVFuZQ2e6u35B98JcY9IzVDtZb3d4QcbtfLtNWkE=","owner": "NixOS","repo": "nixpkgs","rev": "008ce261a7e3c532e792cb8e39482f2cc1b192f5","type": "github"},"original": {"owner": "NixOS","repo": "nixpkgs","type": "github"}},"root": {"inputs": {"flake-utils": "flake-utils","nixpkgs": "nixpkgs"}}},"root": "root","version": 7}