packages feed

literal-flake-input-0.0.4: literal-flake-input.cabal

cabal-version: 3.0
name:          literal-flake-input
version:       0.0.4

synopsis:      Web service converting URLs into archived nix attrsets
description:
    Service translates an HTTP GET path into a nix derivation that can be
    used as a flake input. Such a workaround provides the ability to emulate
    command line arguments in nix flakes.
    
    In addtition to the web service there is a command line tool __e__
    (stands for escape\/encode). The e helps with URL encoding.
    
    == Installation
    #installation#
    
    === Service
    #service#
    
    The service is already deployed at <https://lficom.me lficom.me>
    
    === NixOS module
    #nixos-module#
    
    ==== NixOS with flakes
    #nixos-with-flakes#
    
    Modify @\/etc\/nixos\/flake.nix@ as follows:
    
    >   # ...
    >   inputs = {
    >     # ...
    >     literal-flake-input.url = "github:yaitskov/literal-flake-input";
    >   };
    
    >   # ...
    >         modules = [
    >           literal-flake-input.nixosModules.${system}.default
    >           ({ ... }: {
    >             programs.literal-flake-input {
    >               enable = true;
    >               port = 3000;
    >           })
    >           ./configuration.nix
    >         ];
    
    ==== NixOS without flakes
    #nixos-without-flakes#
    
    >   let
    >     lfi = builtins.fetchGit "htts://github.com/yaitskov/literal-flake-input.git?ref=master";
    >   in {
    >   imports =
    >     [ # ... ./hardware-configuration.nix
    >       "${lfi}/nixos/non-flake-lfi.nix"
    >     ];
    
    >   programs = {
    >     literal-flake-input = {
    >       port = 3000;
    >       enable = true;
    >     };
    >   };
    
    == How to use
    #how-to-use#
    
    The project flake is using
    <https://github.com/yaitskov/literal-flake-input/blob/4342efaa6d4a74143b235f40873bd72f13c02cd3/flake.nix#L8 itself>.
    Another project using lfi is
    <https://github.com/yaitskov/vpn-router vpn-router>.
    
    === Flake template
    #flake-template#
    
    >   # ...
    >   inputs = {
    >     nixpkgs.url = "github:NixOS/nixpkgs";
    >     utils.url = "github:numtide/flake-utils";
    >     c = {
    >       url = "https://lficom.me/name/Bill/";
    >       flake = false;
    >     };
    >   };
    >   outputs = { self, nixpkgs, utils, c }:
    >     utils.lib.eachDefaultSystem (sys:
    >       let
    >         pkgs = nixpkgs.legacyPackages.${sys};
    >         cnf = import c { inherit pkgs; };
    >       in
    >       {
    >         packages.hello =
    >           pkgs.writeShellScriptBin
    >             "hello"
    >             "echo Hello ${cnf.name}";
    >       });
    >   # ...
    
    === Overriding default values
    #overriding-default-values#
    
    > nix build --override-input c \
    >   https://lficom.me/name/Bob/.tar
    
    There is a commant line tool __e__, that helps with boilerplates and
    input validation:
    
    > nix build $(e -name Bob)
    
    The tool supports literal keyword values (e.g. @true@ and @null@),
    strings, numbers, arrays and attribute sets. String quotation is
    optional. All values are parsed and evaluated by __e__ with nix to catch
    typos as soon as possible.
    
    > nix build $(e -an1 true \
    >               -an2 null \
    >               -an3 12 \
    >               -an4 hello world \
    >               -an5 [ 1 2 ] \
    >               -an6 "{x = 1; y = 2; }" \
    >               -an7 x: x + 1)
    
    The above command generates an input link which is going to be resolved
    by the service into:
    
    > {...}: {
    >   an1 = true;
    >   an2 = null;
    >   an3 = 12;
    >   an4 = "hello wolrd";
    >   an5 = [1 2];
    >   an6 = {x = 1; y = 2; };
    >   an7 = x: x + 1;
    > }
    
    If you copy an URL generated by __e__ into a flake for default values,
    then drop @.tar@ suffix.
    
    Alternative URL prefix can be set via environment variable @LFI_SITE@.
    
    == Development environment
    #development-environment#
    
    > $ nix develop
    > $ emacs &
    > $ cabal build
    > $ cabal test
    
    > $ nix build
    > $ ./result/bin/literal-flake-input run
    > $ nix build $(./result/bin/e -static true)
homepage:      http://github.com/yaitskov/literal-flake-input
license:       BSD-3-Clause
license-file:  LICENSE
author:        Daniil Iaitskov
maintainer:    dyaitskov@gmail.com
copyright:     Daniil Iaitkov 2026
category:      System
build-type:    Simple
bug-reports:   https://github.com/yaitskov/literal-flake-input/issues
extra-doc-files:
  changelog.md
tested-with:
  GHC == 9.12.2

source-repository head
  type:
    git
  location:
    https://github.com/yaitskov/literal-flake-input.git

common base
  default-language: GHC2024
  ghc-options: -Wall
  default-extensions:
    DefaultSignatures
    NoImplicitPrelude
    OverloadedStrings
    TemplateHaskell
  build-depends:
      base >=4.7 && < 5
    , optparse-applicative < 1
    , relude >= 1.2.2 && < 2
    , tagged < 1
    , unliftio < 1
    , yesod-core < 1.8

library
  import: base
  hs-source-dirs: src
  exposed-modules:
    LiteralFlakeInput.App
    LiteralFlakeInput.CmdArgs
    LiteralFlakeInput.CmdRun
    LiteralFlakeInput.Nix
    LiteralFlakeInput.Page
    LiteralFlakeInput.Prelude
    LiteralFlakeInput.UrlEncoder
  other-modules:
    Paths_literal_flake_input
  autogen-modules:
    Paths_literal_flake_input
  build-depends:
    , binary                  < 1
    , ekg-core                < 1
    , ekg-wai                 < 1
    , file-embed              < 1
    , hnix                    < 1
    , http-types              < 1
    , monad-logger            < 1
    , ref-tf                  < 1
    , regex-tdfa              < 2
    , tar                     < 1
    , template-haskell        < 3
    , time                    < 2
    , trace-embrace           < 2
    , warp                    < 4
    , warp-tls                < 4
    , wl-pprint-text          < 2

test-suite test
  import: base
  type: exitcode-stdio-1.0
  main-is: Driver.hs
  other-modules:
    LiteralFlakeInput.Test.Nix
    Discovery
  hs-source-dirs:
    test
  ghc-options: -Wall -rtsopts -threaded -main-is Driver
  build-depends:
    , literal-flake-input
    , QuickCheck
    , tasty
    , tasty-discover
    , tasty-hunit
    , tasty-quickcheck

executable literal-flake-input
  import: base
  ghc-options: -Wall -threaded "-with-rtsopts=-T -N"
  main-is: LiteralFlakeInput.hs
  hs-source-dirs: app
  build-depends:
    , literal-flake-input

executable e
  import: base
  ghc-options: -Wall -threaded "-with-rtsopts=-N"
  main-is: EncodeInputUrl.hs
  hs-source-dirs: app
  build-depends:
    , literal-flake-input