Loading pkgs/tools/nix/nixos-option/default.nix +14 −13 Original line number Diff line number Diff line { lib , stdenv , boost , cmake , pkg-config , installShellFiles , nix { lib, stdenv, boost, meson, ninja, pkg-config, installShellFiles, nix, }: stdenv.mkDerivation { name = "nixos-option"; src = ./src; src = ./.; postInstall = '' installManPage ${./nixos-option.8} installManPage ../nixos-option.8 ''; strictDeps = true; nativeBuildInputs = [ cmake meson ninja pkg-config installShellFiles ]; Loading @@ -26,9 +30,6 @@ stdenv.mkDerivation { boost nix ]; cmakeFlags = [ "-DNIX_DEV_INCLUDEPATH=${nix.dev}/include/nix" ]; meta = with lib; { license = licenses.lgpl2Plus; Loading pkgs/tools/nix/nixos-option/meson.build 0 → 100644 +15 −0 Original line number Diff line number Diff line project('nixos-option', 'cpp', version : '0.1.6', license : 'GPL-3.0', ) nix_main_dep = dependency('nix-main', required: true) nix_store_dep = dependency('nix-store', required: true) nix_expr_dep = dependency('nix-expr', required: true) nix_cmd_dep = dependency('nix-cmd', required: true) nix_flake_dep = dependency('nix-flake', required: true) threads_dep = dependency('threads', required: true) nlohmann_json_dep = dependency('nlohmann_json', required: true) boost_dep = dependency('boost', required: true) subdir('src') pkgs/tools/nix/nixos-option/src/CMakeLists.txtdeleted 100644 → 0 +0 −11 Original line number Diff line number Diff line cmake_minimum_required (VERSION 2.6) project (nixos-option) set(NIX_DEV_INCLUDEPATH "" CACHE STRING "path to nix include directory") add_executable(nixos-option nixos-option.cc libnix-copy-paste.cc) target_include_directories(nixos-option PUBLIC "${NIX_DEV_INCLUDEPATH}") target_link_libraries(nixos-option PRIVATE -lnixmain -lnixexpr -lnixstore -lnixutil -lnixcmd) target_compile_features(nixos-option PRIVATE cxx_std_20) install (TARGETS nixos-option DESTINATION bin) pkgs/tools/nix/nixos-option/src/libnix-copy-paste.cc +9 −67 Original line number Diff line number Diff line Loading @@ -2,79 +2,21 @@ // Since they are not, copy/paste them here. // TODO: Delete these and use the ones in the library as they become available. #include <nix/config.h> // for nix/globals.hh's reference to SYSTEM #include "libnix-copy-paste.hh" #include <boost/format/alt_sstream.hpp> // for basic_altstringbuf... #include <boost/format/alt_sstream_impl.hpp> // for basic_altstringbuf... #include <boost/optional/optional.hpp> // for get_pointer #include <iostream> // for operator<<, basic_... #include <nix/types.hh> // for Strings #include <nix/error.hh> // for Error #include <string> // for string, basic_string using nix::Error; using nix::Strings; using std::string; // From nix/src/libexpr/attr-path.cc Strings parseAttrPath(const string & s) { Strings res; string cur; string::const_iterator i = s.begin(); while (i != s.end()) { if (*i == '.') { res.push_back(cur); cur.clear(); } else if (*i == '"') { ++i; while (1) { if (i == s.end()) throw Error("missing closing quote in selection path '%1%'", s); if (*i == '"') break; cur.push_back(*i++); } } else cur.push_back(*i); ++i; } if (!cur.empty()) res.push_back(cur); return res; } #include <nix/print.hh> // for Strings // From nix/src/nix/repl.cc bool isVarName(const string & s) bool isVarName(const std::string_view & s) { if (s.size() == 0) return false; if (s.size() == 0) return false; if (nix::isReservedKeyword(s)) return false; char c = s[0]; if ((c >= '0' && c <= '9') || c == '-' || c == '\'') return false; if ((c >= '0' && c <= '9') || c == '-' || c == '\'') return false; for (auto & i : s) if (!((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z') || (i >= '0' && i <= '9') || i == '_' || i == '-' || i == '\'')) if (!((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z') || (i >= '0' && i <= '9') || i == '_' || i == '-' || i == '\'')) return false; return true; } // From nix/src/nix/repl.cc std::ostream & printStringValue(std::ostream & str, const char * string) { str << "\""; for (const char * i = string; *i; i++) if (*i == '\"' || *i == '\\') str << "\\" << *i; else if (*i == '\n') str << "\\n"; else if (*i == '\r') str << "\\r"; else if (*i == '\t') str << "\\t"; else str << *i; str << "\""; return str; } pkgs/tools/nix/nixos-option/src/libnix-copy-paste.hh +1 −5 Original line number Diff line number Diff line #pragma once #include <iostream> #include <nix/types.hh> #include <string> nix::Strings parseAttrPath(const std::string & s); bool isVarName(const std::string & s); std::ostream & printStringValue(std::ostream & str, const char * string); bool isVarName(const std::string_view & s); Loading
pkgs/tools/nix/nixos-option/default.nix +14 −13 Original line number Diff line number Diff line { lib , stdenv , boost , cmake , pkg-config , installShellFiles , nix { lib, stdenv, boost, meson, ninja, pkg-config, installShellFiles, nix, }: stdenv.mkDerivation { name = "nixos-option"; src = ./src; src = ./.; postInstall = '' installManPage ${./nixos-option.8} installManPage ../nixos-option.8 ''; strictDeps = true; nativeBuildInputs = [ cmake meson ninja pkg-config installShellFiles ]; Loading @@ -26,9 +30,6 @@ stdenv.mkDerivation { boost nix ]; cmakeFlags = [ "-DNIX_DEV_INCLUDEPATH=${nix.dev}/include/nix" ]; meta = with lib; { license = licenses.lgpl2Plus; Loading
pkgs/tools/nix/nixos-option/meson.build 0 → 100644 +15 −0 Original line number Diff line number Diff line project('nixos-option', 'cpp', version : '0.1.6', license : 'GPL-3.0', ) nix_main_dep = dependency('nix-main', required: true) nix_store_dep = dependency('nix-store', required: true) nix_expr_dep = dependency('nix-expr', required: true) nix_cmd_dep = dependency('nix-cmd', required: true) nix_flake_dep = dependency('nix-flake', required: true) threads_dep = dependency('threads', required: true) nlohmann_json_dep = dependency('nlohmann_json', required: true) boost_dep = dependency('boost', required: true) subdir('src')
pkgs/tools/nix/nixos-option/src/CMakeLists.txtdeleted 100644 → 0 +0 −11 Original line number Diff line number Diff line cmake_minimum_required (VERSION 2.6) project (nixos-option) set(NIX_DEV_INCLUDEPATH "" CACHE STRING "path to nix include directory") add_executable(nixos-option nixos-option.cc libnix-copy-paste.cc) target_include_directories(nixos-option PUBLIC "${NIX_DEV_INCLUDEPATH}") target_link_libraries(nixos-option PRIVATE -lnixmain -lnixexpr -lnixstore -lnixutil -lnixcmd) target_compile_features(nixos-option PRIVATE cxx_std_20) install (TARGETS nixos-option DESTINATION bin)
pkgs/tools/nix/nixos-option/src/libnix-copy-paste.cc +9 −67 Original line number Diff line number Diff line Loading @@ -2,79 +2,21 @@ // Since they are not, copy/paste them here. // TODO: Delete these and use the ones in the library as they become available. #include <nix/config.h> // for nix/globals.hh's reference to SYSTEM #include "libnix-copy-paste.hh" #include <boost/format/alt_sstream.hpp> // for basic_altstringbuf... #include <boost/format/alt_sstream_impl.hpp> // for basic_altstringbuf... #include <boost/optional/optional.hpp> // for get_pointer #include <iostream> // for operator<<, basic_... #include <nix/types.hh> // for Strings #include <nix/error.hh> // for Error #include <string> // for string, basic_string using nix::Error; using nix::Strings; using std::string; // From nix/src/libexpr/attr-path.cc Strings parseAttrPath(const string & s) { Strings res; string cur; string::const_iterator i = s.begin(); while (i != s.end()) { if (*i == '.') { res.push_back(cur); cur.clear(); } else if (*i == '"') { ++i; while (1) { if (i == s.end()) throw Error("missing closing quote in selection path '%1%'", s); if (*i == '"') break; cur.push_back(*i++); } } else cur.push_back(*i); ++i; } if (!cur.empty()) res.push_back(cur); return res; } #include <nix/print.hh> // for Strings // From nix/src/nix/repl.cc bool isVarName(const string & s) bool isVarName(const std::string_view & s) { if (s.size() == 0) return false; if (s.size() == 0) return false; if (nix::isReservedKeyword(s)) return false; char c = s[0]; if ((c >= '0' && c <= '9') || c == '-' || c == '\'') return false; if ((c >= '0' && c <= '9') || c == '-' || c == '\'') return false; for (auto & i : s) if (!((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z') || (i >= '0' && i <= '9') || i == '_' || i == '-' || i == '\'')) if (!((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z') || (i >= '0' && i <= '9') || i == '_' || i == '-' || i == '\'')) return false; return true; } // From nix/src/nix/repl.cc std::ostream & printStringValue(std::ostream & str, const char * string) { str << "\""; for (const char * i = string; *i; i++) if (*i == '\"' || *i == '\\') str << "\\" << *i; else if (*i == '\n') str << "\\n"; else if (*i == '\r') str << "\\r"; else if (*i == '\t') str << "\\t"; else str << *i; str << "\""; return str; }
pkgs/tools/nix/nixos-option/src/libnix-copy-paste.hh +1 −5 Original line number Diff line number Diff line #pragma once #include <iostream> #include <nix/types.hh> #include <string> nix::Strings parseAttrPath(const std::string & s); bool isVarName(const std::string & s); std::ostream & printStringValue(std::ostream & str, const char * string); bool isVarName(const std::string_view & s);